﻿// ## 2023/12/15 # 黑店小小二 # 贴合mod设定里的「人才系统扩展」 ##
// ## 2023/05/26 # 江东新风 # 基本完成 ##
// ## 2023/05/18 # 江东新风 # 初次编写 ##
// ## 2020/07/26 ##
/*
设定
培养模式
严格:玩家极少过问教学，由老师自己决定了，容易出现受不了严格指导而出走等各种问题，效果不好。省心推荐
躬亲:几乎每旬过问玩家，通过大量1s可以达到最好效果,大多数人用的方法。
兼顾:介于两者之间，偶尔过问，似乎容易发生探亲事件。
初始值:
非凡:>65
有能:55-65
平凡:45-55
不捻:45以下

资质能力:
杰出:可以达到100
卓著:可达9X
有望:可达8X
普通:达80以下

//经ida查证
学习效果:
极差：10以下
平凡：10以上
良好：18以上
奇迹：25以上
余力含义:
充分:还能长30以上
适当:15以上
些许:1以上
毫无:1以下

兵法和能力关系
统率:主要是水军类兵法，步、骑、弓、弩和攻城也长
武力:步、骑、弓、弩兵和攻城类
智力:谋略为主，智略、策略次之
政治:策略为主，智略、谋略次之

1初始能力  非凡为佳
2资质  杰出为佳
3提拔武将  能力强学得多为佳。
4师事武将  相性性格情义相似、能力强学得多为佳。
5每旬指导武将  尽量选择师事武将擅长的兵法，不要选择那些师事武将不擅长的领域。
6运气

有两个途径可学会兵法
。自动学会 (「亲身」指导方针较易，指导武将或兵士「知力」越高越易)
。选择训练方法学会 (「亲身」指导方针较易)

要让兵士学到兵法，指导武将懂得兵法越多越有利。但有时兵士也能学到指导武将不懂的兵法，指导武将自己也有可能藉机学会新的兵法。

学会单一兵法
------------
简单兵法：学会相同兵法系统中熟练度最低的兵法
困难兵法：学会相同兵法系统中熟练度最高的兵法
学习医术：学会「治疗」兵法
深山闭关：学会「幻术」或「妖术」兵法

学会两种或以上兵法
------------------
锻练武术：学会「歩兵系」(两种或以上)兵法
锻练弓术：学会「弓骑系」(两种或以上)兵法
锻练马术：学会「骑兵系」(两种或以上)兵法
学习操船：学会「水军系」(两种或以上)兵法
学习敷设：学会「造营」「石兵」「罠破」「罠」兵法 (两种或以上)
说精神论：学会「教唆」「混乱」「心攻」「骂声」「鼓舞」兵法 (两种或以上)
编撰兵法：指导武将及兵士一起挑战未学会的兵法
传授知识：指导武将向兵士传授自己已学会的兵法
指导武将自定：完全随机学会

学会相同兵法系统所有兵法
------------------------
集中讲义：学会「攻城系」「知识系」「战略系」「策略系」其中一系所有兵法
参加教练：学会「歩兵系」「骑兵系」「弓骑系」「弩兵系」其中一系所有兵法
进行特训：学会「歩兵系」「骑兵系」「弓骑系」「弩兵系」「水军系」其中一系所有兵法

培养小兵时，学得兵法的同时，也随之增长了四维，基本如下:
步兵兵法学得:增长统帅、武力
骑兵兵法学得:增长统帅、武力
弩兵兵法学得:增长武力、统帅
弓骑兵法学得:增长武力、统帅
水军兵法学得:增长统帅、智力
攻城兵法学得:增长武力、智力
智略兵法学得:增长政治、智力
谋略兵法学得:增长智力、政治
策略兵法学得:增长智力、政治

！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
生病会导致时间进行而不学习东西
外出流浪和探亲之类的，时间不会进行，其实影响最终结果？时间不进行如何判定消失？？-----√   

小兵列传-----√
小兵初始能力和最大能力的调整-----√

发现小兵的事件-攻占敌方城市，消灭敌方部队。  -----√                              消灭敌势力 攻陷敌都市 捕获敌武将 发动兵法
培养属性增长适当削减-----√   
适性增长适度调高-----√   
特殊事件对能力的影响  -----√   
最终特技的习得--暂时做了根据能力生成匹配特技 -----√ ×
*/
namespace 小兵拔擢
{
	const bool 测试模式 = false;
	//  可用武将槽
	const bool slot_新武将 = true;		//999-850
	const bool slot_古武将 = true;		//849-800
	const bool slot_史实武将 = true;	//699-0'
	
	const bool 类型同提拔者 = false;
	const int 女性占比 = 20;
	const int 新人才能力倍率 = 75;
	const int 新人才资质倍率 = 120;
	const int 人才资质上限 = 100;
	const int 人才能力上限 = 70;
	const int 人才适性上限 = 1;
	const int 人才适性标准 = 0;
	const int 基础欧皇率 = 10;
	const int 基础非酋率 = 10;
	const array<string> 能力名 = { "统率","武力","智力","政治","魅力" };
	const array<string> 训练项目 = { "沙盘模拟","锻炼武术","传授知识","研习政略","修身之道","学习枪术","学习戟法","学习弓术","学习马术","学习攻城","学习操船"};
	const array<string> 项目描述 = { "统御之道","武术","谋略","政略","修身之道","枪术","戟法","弓术","马术","攻城","操船"};
	const array<array<int>> 训练项目收益 = { 
		{1300,200,1100,200,200,40,40,40,40,40,40},
{800,1300,300,200,300,60,60,60,90,0,0},
{400,0,1300,900,400,30,30,30,30,60,60},
{200,0,400,1700,700,0,0,0,0,120,120},
{200,800,200,200,1600,0,0,80,0,80,80},
{900,900,200,200,200,400,0,0,0,0,0},
{1100,700,200,200,200,0,400,0,0,0,0},
{900,200,700,300,300,0,0,400,0,0,0},
{900,1100,200,200,0,0,0,0,400,0,0},
{900,200,800,500,0,0,0,0,0,400,0},
{900,300,700,300,200,0,0,0,0,0,400}
	};
	const array<string> 兵种名 = {"枪兵","戟兵","弩兵", "骑兵", "兵器","水军"};
	const array<array<int>> 事件基础收益 = {
		{/*精进1*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*精进2*//*统率*/400,/*武力*/400,/*智力*/400,/*政治*/400,/*魅力*/400},
{/*思慕*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*不和*//*统率*/200,/*武力*/200,/*智力*/200,/*政治*/200,/*魅力*/200},
{/*生病*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*延长修行*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*学生更换老师1*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*学生更换老师2*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*老师更换老师*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*学生离开1*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*学生离开2*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*回乡探亲*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*流浪旅行1*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*流浪旅行2*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*对抗*//*统率*/300,/*武力*/300,/*智力*/300,/*政治*/300,/*魅力*/300},
{/*老师能力好*//*统率*/400,/*武力*/400,/*智力*/400,/*政治*/400,/*魅力*/400},
{/*老师能力差*//*统率*/200,/*武力*/200,/*智力*/200,/*政治*/200,/*魅力*/200},
{/*师生相性好*//*统率*/400,/*武力*/400,/*智力*/400,/*政治*/400,/*魅力*/400},
{/*师生相性差*//*统率*/200,/*武力*/200,/*智力*/200,/*政治*/200,/*魅力*/200},
{/*学习进度好*//*统率*/400,/*武力*/400,/*智力*/400,/*政治*/400,/*魅力*/400},
{/*学习进度差*//*统率*/200,/*武力*/200,/*智力*/200,/*政治*/200,/*魅力*/200},
{/*进度反应1*//*统率*/400,/*武力*/400,/*智力*/400,/*政治*/400,/*魅力*/400},
{/*进度反应2*//*统率*/200,/*武力*/200,/*智力*/200,/*政治*/200,/*魅力*/200},
{/*生病2*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*恢复*//*统率*/400,/*武力*/400,/*智力*/400,/*政治*/400,/*魅力*/400},
{/*兵法1*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*兵法2*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
{/*兵法3*//*统率*/0,/*武力*/0,/*智力*/0,/*政治*/0,/*魅力*/0},
	};
	const bool use_designated_name = true;
	//  姓
	const array<string> sei_ = { "韦","于","卫","袁","阎","王","何","华","贾","贺","郭","霍","郝","甘","管","简","关","韩","颜","纪",
									"魏","牛","许","桥","姜","龚","虞","严","胡","顾","吴","吾","黄","侯","孔","高","崔","蔡","施","谢",
									"车","朱","周","州","徐","向","焦","蒋","邵","秦","沈","邹","石","薛","全","苏","宋","曹","孙","戴",
									"谭","张","赵","陈","丁","程","郑","典","田","杜","党","唐","董","陶","邓","马","裴","樊","潘","万",
									"费","武","冯","文","方","鲍","庞","穆","孟","毛","俞","杨","雍","罗","雷","李","陆","刘","吕","凌",
									"梁","廖","鲁","卢","公孙", "司马","太史", "淳于", "高堂", "皇甫", "蒋义", "成公", "夏侯", "诸葛" };
	//  男-名
	const array<string> mei_m = { "安","晏","威","异","维","遗","彝","懿","韦","祎","毓","昱","彧","允","胤","宇","羽","云","叡","荣",
									"英","卫","颍","莹","奕","怿","悦","越","延","炎","燕","渊","衍","焉","琬","琰","应","横","鸯","恩",
									"温","和","化","嘉","华","嘏","会","恢","怀","楷","玠","亥","凯","盖","艾","恺","闿","恪","核","傕",
									"干","桓","咸","奂","焕","瓘","含","玩","颜","喜","基","既","纪","轨","冀","熙","逵","琦","颀","仪",
									"宜","义","羲","顗","休","宫","球","巨","据","享","协","匡","乔","恭","矫","业","勖","嶷","均","欣",
									"钦","禁","金","瑾","钧","歆","昕","银","诩","珝","虞","训","勋","群","珪","惠","景","经","琼","炅",
									"厥","干","俭","坚","建","宪","权","谦","贤","显","虔","骞","元","原","严","玄","彦","俨","固","虎",
									"祜","兴","广","康","弘","抗","昂","晃","洪","浩","纮","纲","贡","伉","旷","皓","合","鹄","昏","浑",
									"济","朔","策","索","纂","赞","粲","瓒","师","志","旨","芝","咨","汜","慈","竺","质","骘","儒","寿",
									"授","周","就","修","秀","秋","绣","习","袭","丑","缉","修","充","戎","柔","柔","淑","肃","术","术",
									"俊","峻","浚","浚","畯","循","纯","遵","顺","庶","绪","舒","胜","尚","彰","承","升","昭","松","涉",
									"祥","章","绍","象","赏","劭","敞","璋","翔","韶","丞","式","植","寔","稷","谡","信","真","进","震",
									"沈","轸","谌","仁","任","遂","随","蕤","崇","嵩","性","成","政","正","盛","静","齐","靖","旌","靓",
									"籍","绩","节","旋","诠","选","暹","瞻","阐","然","禅","祖","宗","曾","双","仓","爽","操","综","琮",
									"则","续","逊","巽","岱","泰","卓","泽","达","堪","丹","端","耽","诞","谭","治","冲","冲","中","仲",
									"忠","胄","畴","稠","褚","宠","朝","超","肇","昶","直","綝","通","定","悌","桢","铁","典","甸","图",
									"都","度","登","当","统","到","腾","韬","彤","铜","德","特","惇","宁","巴","霸","马","沛","配","买",
									"柏","薄","邈","班","范","丕","飞","毗","斐","备","谧","表","豹","评","彬","斌","旻","布","普","阜",
									"孚","武","馥","宓","奋","平","聘","辟","圃","甫","辅","封","奉","宝","芳","褒","苞","鲂","望","楙",
									"瑁","髦","丰","凤","本","翻","满","曼","茂","蒙","默","门","瑜","熊","优","由","雄","融","攸","预",
									"豫","舆","杨","耀","晔","耀","雍","繇","翼","弋","翊","览","兰","略","隆","亮","梁","良","辽","陵",
									"凌","琳","累","礼","灵","烈","鲁","朗","淮","伯敬","永庆","冠文","昌辉","传忠","宗华","振藩","昭铭",
									"敬梓","承恩","道成","玉祥","其美","元衡","仁贵" };
	//  女-名
	const array<string> mei_f = { "月英","毓美","莹","艳","圆圆","婉君","忆如","雅琴","晓涵","玉玲","桂英","洁","妍","红","子怡","思敏",
									"秀娥","湘华","如玉","如凤","倩容","念慈","梅芳","菲","薇","媚娘","柏芝","碧芳","窈","莉","丽","媛",
									"嫣然", "姬", "兰香", "圆圆", "芙蓉", "婉君", "玉华", "雪", "蕊","香香", "飞燕", "玉环", "若兰", "小小",
									"灵儿", "丽华", "婕妤", "诗诗", "琬", "梅", "杏儿", "春华", "秋月", "芳", "玉英", "玉兰", "惠", "佩",
									"文君", "妙", "凤", "巧巧", "珠", "雨荷", "如月", "玉珠", "燕燕", "玉", "莺", "雅", "芝", "慧", "兰",
									"静", "淑", "翠", "芬", "春", "菊", "晶", "青", "莹", "珍", "黛", "琳", "彩", "清", "蓉", "卿卿", "媚",
									"蝉", "娴", "宓", "娜", "玉奴", "娇", "娉", "灵美", "雨", "宝珠", "盈盈", "蝶凤", "玉娥", "昭", "琰",
									"华", "氏", "玲", "琪","紫琼", "瑶", "琴", "璃", "瑜", "莲", "莎", "姒", "芸", "美" };
	// 字号的第一个字
	const array<string> azana_0 = { "伯", "仲", "叔", "季", "幼", "早", "孟", "显", "惠", "雅",
									"陆", "德", "仁", "少", "公", "子", "弘", "平", "文", "长",
									"奉", "士", "元", "玄", "守", "兴", "正", "曼", "义", "汉" };



	const bool 调试模式 = false;
	pk::random randint(pk::rand());

	class Main
	{
		pk::array<bool> flag_has_child(1000, false);    //  flag_has_child[i] == true 说明i号武将有孩子

		bool show_stat_report = false;
		string info_stat_report;
		//事件用暂存参数
		pk::force@ force_;

		Main()
		{
			pk::bind(111, pk::trigger111_t(OnTurnStart));
			pk::bind(120, pk::trigger120_t(func_信息显示_事件));
			pk::bind(171, pk::trigger171_t(onUnitRemove));
		}

		void OnTurnStart(pk::force@ force)
		{
			if (!ch::get_set_p(0).get_mod_set(人才选拔扩展_开关)) return; 
			if (force.is_player())
			{
				@force_ = @force;
				auto force_t = ch::get_force_p(force.get_id());
				/**/
				if (force_t.talent_id == force_t.teacher_id and force_t.talent_id != -1)
				{
					//此情况发生，意味着数据没有初始化，那就进行初始化---但这样初始化的数据会被反复初始化
					force_t.init_talent_info();
				}
				//pk::trace("测试小兵1");
				if (pk::is_valid_person_id(force_t.talent_id))//得考虑存档异常出现阿会喃的情况
				{
					//pk::trace("测试小兵2");
					if (测试模式) pk::scene(pk::scene_t(scen_测试小兵事件)); 
					else
					{
						pk::scene(pk::scene_t(小兵事件总纲));
					}
				}
				else
				{
					//pk::trace("测试小兵3");
					if (pk::rand_bool(30) or 测试模式)
					{
						if (测试模式)
						{
							//pk::trace("测试小兵4");
							generate_talent_seed(pk::get_person(武将_赵云));
						}
						int person_id = force_t.discovered_by;
						if (pk::is_valid_person_id(person_id))
						{
							//pk::trace(pk::format("测试小兵5{},{},{}",person_id, pk::get_person(person_id).get_force_id() ,force.get_id()));
							if (pk::get_person(person_id).get_force_id() == force.get_id())
							{
								//pk::trace("测试小兵6");
								pk::scene(pk::scene_t(scen_发现小兵));
							}
							else
							{
								//提拔者非同势力，重置？
								force_t.init_talent_info();
							}
						}
					}
			
				}

				@force_ = null;
			}

			return;
		}


		void func_信息显示_事件()
		{
			if (!show_stat_report) return;
			int line = 7;
			int middle = int(pk::get_resolution().width) / 2;
			int left = middle - 140;
			int right = middle + 140;
			int top = 5;
			int top_start = top + 300;
			pk::point leftdown = pk::point(left + 280, top_start + 28 * line);
			pk::draw_filled_rect(pk::rectangle(pk::point(left + 5, top_start), leftdown), ((0xff / 2) << 24) | 0x777777);

			pk::draw_text(info_stat_report, pk::point(left + 10, top_start), 0xffffffff, FONT_BIG, 0xff000000);

		}

		void onUnitRemove(pk::unit @unit, pk::hex_object @dst, int type)
		{
			if (!ch::get_set_p(0).get_mod_set(人才选拔扩展_开关)) return; 
			// pk::trace(pk::format("onUnitRemove0", 1));
			if (type == 1) return;//排除部队进入
			if (dst is null)
				return;

			if (type == 0)
			{
				pk::unit @dst_unit = dst.get_type_id() == pk::unit::type_id ? dst : null;
				//仅在部队击破部队时发生
				if (dst_unit !is null)
				{
					if (pk::is_enemy(unit, dst_unit))
					{
						if (pk::rand_bool(10))//击破部队20概率生成小兵种子，小兵种子可覆盖
						{
							pk::person@ leader = pk::get_person(dst_unit.leader);
							if (leader !is null) generate_talent_seed(leader);
						}
					}

				}
			}
		}


		string 获取小兵初始能力(pk::person@ talent, string talent_name)
		{
			bool show_stat = false;
			auto force_t = ch::get_force_p(pk::get_current_turn_force_id());
			string info_能力报告_t = pk::encode(pk::format("      \x1b[1x{}\x1b[0x的能力报告\n", talent_name));
			string info_描述 = pk::encode("      现在      资质\n");
			string info_统率;
			string info_武力;
			string info_智力;
			string info_政治;
			string info_魅力;

			if (show_stat)
			{
				info_统率 = pk::encode(pk::format("统率：{}{}      {}{}\n", 获取初始能力评价(talent.base_stat[武将能力_统率]), talent.base_stat[武将能力_统率] , 获取资质评价(force_t.max_stat[武将能力_统率]), force_t.max_stat[武将能力_统率] ));
				info_武力 = pk::encode(pk::format("武力：{}{}      {}{}\n", 获取初始能力评价(talent.base_stat[武将能力_武力]), talent.base_stat[武将能力_武力] , 获取资质评价(force_t.max_stat[武将能力_武力]), force_t.max_stat[武将能力_武力] ));
				info_智力 = pk::encode(pk::format("智力：{}{}      {}{}\n", 获取初始能力评价(talent.base_stat[武将能力_智力]), talent.base_stat[武将能力_智力] , 获取资质评价(force_t.max_stat[武将能力_智力]), force_t.max_stat[武将能力_智力] ));
				info_政治 = pk::encode(pk::format("政治：{}{}      {}{}\n", 获取初始能力评价(talent.base_stat[武将能力_政治]), talent.base_stat[武将能力_政治] , 获取资质评价(force_t.max_stat[武将能力_政治]), force_t.max_stat[武将能力_政治] ));
				info_魅力 = pk::encode(pk::format("魅力：{}{}      {}{}\n", 获取初始能力评价(talent.base_stat[武将能力_魅力]), talent.base_stat[武将能力_魅力] , 获取资质评价(force_t.max_stat[武将能力_魅力]), force_t.max_stat[武将能力_魅力] ));
			}
			else
			{
				info_统率 = pk::encode(pk::format("统率：{}      {}\n", 获取初始能力评价(talent.base_stat[武将能力_统率]), 获取资质评价(force_t.max_stat[武将能力_统率])));
				info_武力 = pk::encode(pk::format("武力：{}      {}\n", 获取初始能力评价(talent.base_stat[武将能力_武力]), 获取资质评价(force_t.max_stat[武将能力_武力])));
				info_智力 = pk::encode(pk::format("智力：{}      {}\n", 获取初始能力评价(talent.base_stat[武将能力_智力]), 获取资质评价(force_t.max_stat[武将能力_智力])));
				info_政治 = pk::encode(pk::format("政治：{}      {}\n", 获取初始能力评价(talent.base_stat[武将能力_政治]), 获取资质评价(force_t.max_stat[武将能力_政治])));
				info_魅力 = pk::encode(pk::format("魅力：{}      {}\n", 获取初始能力评价(talent.base_stat[武将能力_魅力]), 获取资质评价(force_t.max_stat[武将能力_魅力])));

			}
			info_能力报告_t = info_能力报告_t + info_描述 + info_统率 + info_武力 + info_智力 + info_政治 + info_魅力;
			return info_能力报告_t;
		}

		string 获取小兵中期描述(pk::person@ talent, string talent_name, pk::int_int &out out_info)
		{
			bool show_stat = false;
			auto force_t = ch::get_force_p(pk::get_current_turn_force_id());
			array<int> chengguo = {0,0,0,0,0};
			array<int> yuli = { 0,0,0,0,0 };
			//array<string> stat_type = { "统率","武力","智力","政治","魅力" };
			string stat_desc = "";
			//表述最强的成果？
			int best_stat_type = -1;
			int best_chengguo = -1;
			for (int i = 0; i < 武将能力_末; ++i)
			{
				chengguo[i] = talent.base_stat[i] - force_t.init_stat[i];
				yuli[i] = force_t.max_stat[i] - talent.base_stat[i];
				if (best_chengguo < chengguo[i])
				{
					best_chengguo = chengguo[i];
					best_stat_type = i;
				}
				if (show_stat) stat_desc += pk::encode(pk::format("{}：{}{}      {}{}\n", 能力名[i], 获取成果评价(chengguo[i]), chengguo[i], 获取余力评价(yuli[i]), yuli[i]));
				else {
					stat_desc += pk::encode(pk::format("{}：{}      {}\n", 能力名[i], 获取成果评价(chengguo[i]),  获取余力评价(yuli[i])));
				}
			}
			out_info.first = best_stat_type;
			int second = (chengguo[best_stat_type] > 25)?0:((chengguo[best_stat_type] > 18)?1:((chengguo[best_stat_type] > 10) ? 2:3));

			out_info.second = second;

			string info_能力报告_t = pk::encode(pk::format("      \x1b[1x{}\x1b[0x的成果报告\n", talent_name));
			string info_描述 = pk::encode("      成果      余力\n");
			//string info_统率 = pk::encode(pk::format("统率：{}{}      {}{}\n", 获取成果评价(chengguo[武将能力_统率]), 获取余力评价(force_t.max_stat[武将能力_统率] - talent.base_stat[武将能力_统率])));
			//string info_武力 = pk::encode(pk::format("武力：{}{}      {}{}\n", 获取成果评价(talent.base_stat[武将能力_武力] - force_t.init_stat[武将能力_武力]), 获取余力评价(force_t.max_stat[武将能力_武力] - talent.base_stat[武将能力_武力])));
			//string info_智力 = pk::encode(pk::format("智力：{}{}      {}{}\n", 获取成果评价(talent.base_stat[武将能力_智力] - force_t.init_stat[武将能力_智力]), 获取余力评价(force_t.max_stat[武将能力_智力] - talent.base_stat[武将能力_智力])));
			//string info_政治 = pk::encode(pk::format("政治：{}{}      {}{}\n", 获取成果评价(talent.base_stat[武将能力_政治] - force_t.init_stat[武将能力_政治]), 获取余力评价(force_t.max_stat[武将能力_政治] - talent.base_stat[武将能力_政治])));
			//string info_魅力 = pk::encode(pk::format("魅力：{}{}      {}{}\n", 获取成果评价(talent.base_stat[武将能力_魅力] - force_t.init_stat[武将能力_魅力]), 获取余力评价(force_t.max_stat[武将能力_魅力] - talent.base_stat[武将能力_魅力])));

			info_能力报告_t = info_能力报告_t + info_描述 + stat_desc;//info_统率 + info_武力 + info_智力 + info_政治 + info_魅力;
			return info_能力报告_t;
		}

		void scen_发现小兵()
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			force_t.talent_event_happened = true;//只要走到这里就默认已经发生过了
			pk::person@ kunshu = pk::get_person(pk::get_force(force_id).kunshu);
			string kunshu_name = pk::decode(pk::get_name(kunshu));
			pk::person@ promoter = pk::get_person(force_t.discovered_by);
			string promoter_name = pk::decode(pk::get_name(promoter));

			
			//pk::person@ teacher = pk::get_person(武将_荀彧);
			//string teacher_name = pk::decode(pk::get_name(teacher));
			//设置士兵的随机名字
			pk::person@ new_person = getEmptyPerson();
			if (new_person is null) return;
			int sex = (pk::rand_bool(女性占比)) ? 1 : 0;
			int 欧皇率 = 基础欧皇率;
			int 非酋率 = (基础非酋率 - promoter.stat[4] / 10 + 8);
			int 翘楚率 = 4;
			int luck = initNewPerson(new_person, sex, promoter, 欧皇率, 非酋率, 翘楚率);
			init_belong(new_person, pk::get_building(promoter.service), false, 身份_未登场, 0, 0);
			pk::person@ talent = @new_person;
			string talent_name = pk::decode(talent.sei+ talent.mei);
			pk::trace("talent_id:" + talent.get_id());

			pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x发现了某个有才能的士兵，将他召至跟前。", promoter_name)));
			pk::message_box(pk::encode(pk::format("这个名叫\x1b[01x{}\x1b[0x的士兵，\n让人觉得他的资质与众不同。", talent_name)),promoter);
			pk::message_box(pk::encode(pk::format("这个人只要加以锻炼，\n假以时日，他\x1b[01x{}\x1b[0x必将成为出色的人才。", talent_name)), promoter);
			info_stat_report = 获取小兵初始能力(talent, talent_name);
			show_stat_report = true;
			pk::message_box(pk::encode("这个人的能力，\n在我看来是这样的。"), promoter);
			show_stat_report = false;
			info_stat_report = "";
			force_t.talent_id = talent.get_id();
			//展示能力窗口---参考类三顾茅庐事件信息的显示
			/*
			xx的能力报告
			         现在  资质
			统率：   非凡  卓著
			武力：   非凡  卓著
			智力：   非凡  卓著
			政治：   非凡  卓著
			魅力：   非凡  卓著
			*/
			pk::message_box(pk::encode(pk::format("那么，为了将\x1b[01x{}\x1b[0x的能力\n提升至最高的境界，\n应该想个最佳的训练方案。", talent_name)), promoter);
			pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n请决定\x1b[02x{}\x1b[0x的指导武将。", kunshu_name, talent_name)), promoter);
			//展示选择武将列表
			pk::list<pk::person@> person_list = pk::get_person_list(force_,pk::mibun_flags(身份_君主, 身份_都督,身份_太守,身份_一般));
			set_teacher(force_id, person_list, true, talent_name);

			
		}

		void scen_培养小兵()
		{
			//pk::person@ kunshu = pk::get_person(武将_曹操);
			//string kunshu_name = pk::decode(pk::get_name(kunshu));
			//settinginfo@ set_t = @setting_ex;
			int force_id = pk::get_current_turn_force_id();
			pk::force@ force = pk::get_force(force_id);
			auto force_t = ch::get_force_p(force_id);
			pk::person@ promoter = pk::get_person(force_t.discovered_by);
			string promoter_name = pk::decode(pk::get_name(promoter));
			pk::person@ talent = pk::get_person(force_t.talent_id);
			string talent_name = pk::decode(talent.sei + talent.mei);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			string teacher_name = pk::decode(pk::get_name(teacher));

			pk::message_box(pk::encode(pk::format("这时的\x1b[01x{}\x1b[0x等人......。", teacher_name)));
			//san9ME msg编号12613开始
			//剧情1 生病

		}

		void scen_测试小兵事件()
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			for (int i = 0; i <= 12; ++i)
			{
				pk::fade(0);
				pk::sleep();
				pk::fade(255);
				小兵事件总纲();

				if (force_t.remained_time == 0) break;
			}
		}

		void 小兵事件总纲()
		{
			//第一旬是正常培养，不需要特殊事件
			//未发生延长事件的第5旬为中期总结
			//最后旬是总结，也不需要特殊事件
			//外出期间不会缩短remained_time
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			force_t.talent_event_happened = true;//只要走到这里就默认已经发生过了
			talent_return_event();
			talent_disapear_event();//要不在此加入老师身份变化导致的事件？
			if (force_t.is_out)
			{
				force_t.out_time += 1;
				return;
			}
			if (force_t.remained_time == 255) return;
			if (force_t.remained_time > 0) force_t.remained_time -= 1;
			//pk::trace("force_t.remained_time" + force_t.remained_time);

			
			bool result1 = special_event();
			//pk::trace("special_event" + result1);
			if (!result1)
			{
				if (force_t.remained_time < 9 and !force_t.is_out)
				{
					//剩余情况兵法培养--注意，非君主亲自培养下，询问比例不高
					//严格为专注能力，均衡是平衡能力和兵法，躬亲是专注兵法
					bool result2 = tactic_train_event();
					//pk::trace("tactic_train_event" + result2);
					if (!result2)
					{
						bool result3 = special_event2();//理论上此事件应该必然发生
						//pk::trace("special_event2" + result3);
						if (!result3)
						{
							scen_小兵兵法培养(true);//设计了兵法学习作为其他事情不发生的最终归宿
						}
					}
				}
			}
			事件_小兵中期汇报();
			事件_小兵培训结束();

			return;
		}

		//触发条件基本已经完全参照三国志9的条件设计了
		bool special_event()
		{
			pk::trace("special_event");
			//延长修行，学生更换老师1，老师更换老师，学生离开1，回乡探亲，对抗，流浪旅行
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			//条件函数，参照原版
			if (force_t.remained_time >= 9 or force_t.remained_time % 3 != 2 or force_t.is_out or cal_special_event_count(force_t) >= 3) return false;
			pk::trace("special_event   2");
			pk::person@ talent = pk::get_person(force_t.talent_id);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			if (!force_t.time_extended and !ch::test_bit(force_t.train_event, 小兵事件_延长修行))
			{
				pk::trace("special_event小兵事件_延长修行");
				if (force_t.remained_time > 0 and force_t.remained_time < 3)
				{
					int init_sum = 0;
					int now_sum = 0;
					for (int i = 0; i < 武将能力_末; ++i)
					{
						init_sum += force_t.init_stat[i];
						now_sum += talent.base_stat[i];
					}
					int eff = pk::max(0, init_sum - now_sum + 88);
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < eff)//概率算法完全参考原版设定
					{
						int value = 0;
						if ((force_t.max_stat[武将能力_统率] - talent.base_stat[武将能力_统率]) < 10) value += 1;
						if ((force_t.max_stat[武将能力_武力] - talent.base_stat[武将能力_武力]) < 10) value += 1;
						if ((force_t.max_stat[武将能力_智力] - talent.base_stat[武将能力_智力]) < 10) value += 1;
						if ((force_t.max_stat[武将能力_政治] - talent.base_stat[武将能力_政治]) < 10) value += 1;
						if ((force_t.max_stat[武将能力_魅力] - talent.base_stat[武将能力_魅力]) < 10) value += 1;
						if (value > 2)
						{
							if (pk::rand_bool(30))
							{
								pk::trace("special_event小兵事件_延长修行1");
								小兵培养事件(小兵事件_延长修行);
								return true;
							}
						}
					}
				}
			}
			//更换老师的概率是否可以调整
			if (!ch::test_bit(force_t.train_event, 小兵事件_学生更换老师1) and !ch::test_bit(force_t.train_event, 小兵事件_学生更换老师1))
			{
				if (force_t.remained_time > 0 and force_t.remained_time != 8)
				{
					pk::trace("special_event小兵事件_学生更换老师1");
					//什么情况学生会要求更换老师？相性相差大，思慕事件？能力相差大？
					int value = 0;
					if ((int(talent.base_stat[武将能力_统率]) - int(teacher.stat[武将能力_统率])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_武力]) - int(teacher.stat[武将能力_武力])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_智力]) - int(teacher.stat[武将能力_智力])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_政治]) - int(teacher.stat[武将能力_政治])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_魅力]) - int(teacher.stat[武将能力_魅力])) > 10) value += 1;
					if (value > 0)
					{
						if (get_rand_int(talent.base_stat[武将能力_统率], 100) < int(2 * (8 - force_t.remained_time)))
						{
							小兵培养事件(小兵事件_学生更换老师1);
							return true;
						}
					}
				}
			}
			if (!ch::test_bit(force_t.train_event, 小兵事件_老师更换老师))
			{
				if (force_t.remained_time > 0 and force_t.remained_time != 8)
				{
					pk::trace("special_event小兵事件_老师更换老师");
					//源码里老师要求更换好像只跟老师政治有关？
					int value = 0;
					if ((int(talent.base_stat[武将能力_统率]) - int(teacher.stat[武将能力_统率])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_武力]) - int(teacher.stat[武将能力_武力])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_智力]) - int(teacher.stat[武将能力_智力])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_政治]) - int(teacher.stat[武将能力_政治])) > 10) value += 1;
					if ((int(talent.base_stat[武将能力_魅力]) - int(teacher.stat[武将能力_魅力])) > 10) value += 1;

					int rate = value * 8;
					if (pk::get_aishou_distance(teacher, talent.get_id()) > 50) rate += 10;
					if (pk::get_aishou_distance(teacher, talent.get_id()) < 30) rate -= 10;
					int count = get_negtive_event_count(force_t);
					rate += count * 10 ;
					if (teacher.giri <= 义理_普通)  rate += 10;
					rate = pk::min(90, rate);
					if (pk::rand_bool(rate))
					{
						小兵培养事件(小兵事件_老师更换老师);
						return true;
					}
				}
			}
			//出走，探亲，流浪，对抗
			//出走事件判定下一些对抗老师的事件是否发生
			if (!check_talent_out_event(force_t) and force_t.remained_time != 0 and force_t.remained_time != 8)
			{
				if (force_t.talent_status != 4)
				{
					pk::trace("special_event小兵事件_学生出走1");
					int method_eff = force_t.teaching_method == 1 ? 10 : 0;
					int aishou_distance_eff = pk::max(0, pk::get_aishou_distance(teacher, talent.get_id()) / 7);
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < method_eff + aishou_distance_eff)
					{
						小兵培养事件(小兵事件_学生出走1);
						return true;
					}
				}
			}
			//什么情况下会发生探亲呢
			if (!ch::test_bit(force_t.train_event, 小兵事件_返乡探亲))
			{
				int remained_time = force_t.remained_time;
				if (remained_time > 0)
				{
					pk::trace("special_event小兵事件_返乡探亲");
					//所以剩余时间越少，越容易发生探亲？
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < (10 - remained_time))
					{
						小兵培养事件(小兵事件_返乡探亲);
						return true;
					}
				}

			}

			int remained_time = force_t.remained_time;
			if (check_talent_out_event(force_t) or remained_time == 0 or remained_time == 8 or get_rand_int(talent.base_stat[武将能力_统率], 100) >= (10 - remained_time))//对抗是出走事件之后会发生的？神奇
			{
				pk::trace("special_event小兵事件_对抗");
				if (!ch::test_bit(force_t.train_event, 小兵事件_对抗) and remained_time >= 3 and teacher.stat[武将能力_武力] < 70 and teacher.stat[武将能力_统率] < 70 and force_t.teaching_method == 1 and force_t.talent_status >= 2)
				{
					int aishou_distance_eff = pk::max(10, pk::get_aishou_distance(teacher, talent.get_id()) / 2);
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < aishou_distance_eff)
					{
						小兵培养事件(小兵事件_对抗);
						return true;
					}
				}
				return false;

			}
			else
			{
				pk::trace("special_event小兵事件_流浪旅行1");
				小兵培养事件(小兵事件_流浪旅行1);
				return true;
			}


			//return false;
		}

		//触发条件基本已经完全参照三国志9的条件设计了
		bool special_event2()
		{
			pk::trace("special_event2");
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			pk::person@ talent = pk::get_person(force_t.talent_id);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			//老师能力相关--已参照san9
			if (force_t.talent_status <= 2)
			{				
				pk::trace("special_event小兵事件_老师能力差");
				if (teacher.stat[武将能力_统率] < 50)
				{

					if (talent.base_stat[武将能力_武力] + talent.base_stat[武将能力_智力] + 50 > teacher.stat[武将能力_武力] + teacher.stat[武将能力_智力])
					{
						//int rate = (50 - teacher.stat[武将能力_武力]) / 3;
						//设定，老师武力50以下30概率触发，老师武力70以上，
						int rate = pk::min(3, 30 - (teacher.stat[武将能力_武力] - 50));
						int rand_num = get_rand_int(talent.base_stat[武将能力_统率], 100);
						pk::trace("special_event小兵事件_老师能力好 rate:" + rate + ",rand_num:" + rand_num);
						if (rand_num < rate)
						{
							小兵培养事件(小兵事件_老师能力差);
							return true;
						}

					}
				}
			}
			else
			{
				pk::trace("special_event小兵事件_老师能力好");
				if (get_stat_sum(talent)+40 < get_stat_sum(teacher) )
				{
					int str_eff = (teacher.stat[武将能力_武力] - 70);
					int rate = pk::max(5, str_eff / 3 + 5);
					int rand_num = get_rand_int(talent.base_stat[武将能力_统率], 100);
					pk::trace("special_event小兵事件_老师能力好 rate:" + rate + ",rand_num:" + rand_num + ",str_eff" + str_eff);
					if (rand_num < rate)
					{
						小兵培养事件(小兵事件_老师能力好);
						return true;
					}
				}

			}

			if (force_t.teaching_method != 1)
			{

				if (force_t.talent_status < 2)
				{
					pk::trace("special_event 相性，学习进度");
					int aishou_distance = pk::get_aishou_distance(teacher, force_t.talent_id);
					int aishou_eff = pk::max(1, aishou_distance / 7);
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < aishou_eff)
					{
						小兵培养事件(小兵事件_师生相性差);
						return true;
					}
					int aishou_eff2 = 85 - aishou_distance / 8;
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < aishou_eff2)
					{
						小兵培养事件(小兵事件_师生相性好);
						return true;
					}

					//小兵事件_学习进度好
					if (pk::rand_bool(50))
					{
						int value = 0;
						if ((talent.base_stat[武将能力_统率] - force_t.init_stat[武将能力_统率]) > 15) value += 1;
						if ((talent.base_stat[武将能力_武力] - force_t.init_stat[武将能力_武力]) > 15) value += 1;
						if ((talent.base_stat[武将能力_智力] - force_t.init_stat[武将能力_智力]) > 15) value += 1;
						if ((talent.base_stat[武将能力_政治] - force_t.init_stat[武将能力_政治]) > 15) value += 1;
						if ((talent.base_stat[武将能力_魅力] - force_t.init_stat[武将能力_魅力]) > 15) value += 1;

						if (value > 1 and get_rand_int(talent.base_stat[武将能力_统率], 100) < 20)
						{
							小兵培养事件(小兵事件_学习进度好);
							return true;
						}

					}
					int teacher_eff = (pk::max(0, teacher.stat[武将能力_统率] - 85) + pk::max(0, teacher.stat[武将能力_武力] - 85) + pk::max(0, teacher.stat[武将能力_智力] - 85) + pk::max(0, teacher.stat[武将能力_政治] - 85) + pk::max(0, teacher.stat[武将能力_魅力] - 85)) / 5;
					//小兵事件_学习进度差
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < teacher_eff)
					{
						int value2 = 0;
						if ((teacher.stat[武将能力_统率] - talent.base_stat[武将能力_统率]) > 40) value2 += 1;
						if ((teacher.stat[武将能力_武力] - talent.base_stat[武将能力_武力]) > 40) value2 += 1;
						if ((teacher.stat[武将能力_智力] - talent.base_stat[武将能力_智力]) > 40) value2 += 1;
						if ((teacher.stat[武将能力_政治] - talent.base_stat[武将能力_政治]) > 40) value2 += 1;
						if ((teacher.stat[武将能力_魅力] - talent.base_stat[武将能力_魅力]) > 40) value2 += 1;
						if (value2 > 2)
						{
							小兵培养事件(小兵事件_学习进度差);
							return true;
						}
					}


				}

				//精进，思慕，不和
				if (cal_special_event_count(force_t) < 3)
				{
					pk::trace("special_event 精进，思慕，不和");
					bool same_sex = talent.sex == teacher.sex;
					int value = pk::get_aishou_distance(teacher, talent.get_id());
					if (same_sex)
					{
						
						if (force_t.talent_status > 0)
						{
							if (!ch::test_bit(force_t.train_event, 小兵事件_精进1) and !ch::test_bit(force_t.train_event, 小兵事件_精进2))
							{
								if (pk::rand_bool(pk::max(1, 50 - value)) and pk::rand_bool(50))
								{
									小兵培养事件(小兵事件_精进2);
									return true;
								}
							}
						}
						if (force_t.talent_status != 4)
						{
							if (!ch::test_bit(force_t.train_event, 小兵事件_思慕))
							{
								if (pk::rand_bool(pk::max(1, 50 - value)) and pk::rand_bool(50))
								{
									小兵培养事件(小兵事件_思慕);
									return true;
								}
							}
						}
					}

					if (force_t.remained_time > 0)
					{
						if (force_t.talent_status > 0 and force_t.talent_status != 4)
						{
							pk::trace("special_event 不和");
							int eff = pk::min(5, (force_t.teaching_method == 1 ? 0 : 10) + value/7);
							if (get_rand_int(talent.base_stat[武将能力_统率], 100) < eff)
							{
								小兵培养事件(小兵事件_不和);
								return true;
							}
						}
					}

				}

				//生病
				if (force_t.talent_status <= 1 and get_rand_int(talent.base_stat[武将能力_统率], 100) < 10)
				{
					小兵培养事件(小兵事件_生病2);
					return true;
				}
				//生病2，恢复
				if (cal_special_event_count(force_t) < 3 and !ch::test_bit(force_t.train_event, 小兵事件_生病))
				{
					pk::trace("生病2，恢复");
					bool rate_approve = get_rand_int(talent.base_stat[武将能力_统率], 100) < 10;
					if (rate_approve)
					{
						if (force_t.talent_status > 2)
						{
							小兵培养事件(小兵事件_恢复);
							return true;
						}
						else
						{
							小兵培养事件(小兵事件_生病);
							return true;
						}
					}

				}

			}
			//知难而退，迎难而上
			if (force_t.teaching_method == 1)
			{
				pk::trace("special_event 知难而退，迎难而上");
				if (force_t.talent_status > 0 and get_rand_int(talent.base_stat[武将能力_统率], 100) < 10)
				{
					小兵培养事件(小兵事件_迎难而上);
					return true;
				}
				if (force_t.talent_status != 4 and get_rand_int(talent.base_stat[武将能力_统率], 100) < 10)
				{
					小兵培养事件(小兵事件_知难而退);
					return true;
				}
			}

			//***********************************************************************

			return false;
		}

		//原触发机制不好，改一下
		bool tactic_train_event()
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
		
			pk::person@ talent = pk::get_person(force_t.talent_id);

			int happened_rate = pk::rand(100);
			pk::trace("tactic_train_event happened_rate" + happened_rate);
			if (happened_rate < 80)//80概率一定会触发战法事件
			{
				if (force_t.talent_status != 4 /*还需要判断科学系战法量？选项数*/)
				{
					int method_eff = force_t.teaching_method == 2 ? 15 : (force_t.teaching_method == 1 ? 0 : 5);

					int rate_result = get_rand_int(talent.base_stat[武将能力_统率], 100);
					pk::trace("tactic_train_event 小兵事件_兵法常规 rate" + rate_result);
					//记得游戏中一般选择培养只有2-3次，剩余的都是直接培养
					if (rate_result < 30 + method_eff)
					{
						小兵培养事件(小兵事件_兵法常规);
						return true;
					}

					int int_eff = pk::max(0, (talent.base_stat[武将能力_智力] - 25) / 3);
					rate_result = get_rand_int(talent.base_stat[武将能力_统率], 100);
					pk::trace("tactic_train_event 小兵事件_兵法领悟 rate" + rate_result);
					if (rate_result < int_eff)
					{
						小兵培养事件(小兵事件_兵法领悟);
						return true;
					}


					method_eff = force_t.teaching_method == 2 ? 40 : (force_t.teaching_method == 1 ? 5 : 10);
					int status_eff = force_t.talent_status == 0 ? 10 : (force_t.talent_status == 1 ? 5 : 0);
					int rate = method_eff + status_eff + talent.base_stat[武将能力_智力] / 10;
					if (get_rand_int(talent.base_stat[武将能力_统率], 100) < rate)
					{
						小兵培养事件(小兵事件_兵法3);
						return true;
					}
				}
				else
				{
					scen_小兵兵法培养(true);
					return true;
				}
			}

			return false;
		}

		void 事件_小兵中期汇报()
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			if (force_t.remained_time == 5 and !ch::test_bit(force_t.train_event, 小兵事件_延长修行) and !force_t.is_out)
			{
				pk::force@ force = pk::get_force(force_id);
				pk::person@ kunshu = pk::get_person(force.kunshu);
				string kunshu_name = pk::decode(pk::get_name(kunshu));

				pk::person@ talent = pk::get_person(force_t.talent_id);
				string talent_name = pk::decode(talent.sei + talent.mei);
				pk::person@ teacher = pk::get_person(force_t.teacher_id);
				string teacher_name = pk::decode(pk::get_name(teacher));
				if (kunshu.get_id() != teacher.get_id()) pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n向您报告\x1b[01x{}\x1b[0x的修行成果。", kunshu_name, talent_name)), teacher);
				else pk::message_box(pk::encode(pk::format("让我们检讨一下，\n至今指导\x1b[01x{}\x1b[0x的成果吧！", talent_name)), teacher);
				pk::int_int out_info;
				info_stat_report = 获取小兵中期描述(talent, talent_name, out_info);
				show_stat_report = true;
				int result_desc = out_info.second;
				string stat_desc = 能力名[out_info.first];
				array<string> teacher_say;
				switch (result_desc)
				{
				case 0://成果优秀
					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[02x{}\x1b[0x方面，\n\x1b[01x{}\x1b[0x的成长，\n令人刮目相看。", stat_desc, talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x在\x1b[02x{}\x1b[0x方面，\n得到比预期还高的成果。", talent_name, stat_desc)), teacher);
					break;
				case 1://成果普通
					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[02x{}\x1b[0x的学习成果\n称得上是稳定成长。", stat_desc)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[02x{}\x1b[0x的学习成果普普通通。", stat_desc)), teacher);
					break;
				case 2://成果些微
					pk::message_box(pk::encode(pk::format("\x1b[02x{}\x1b[0x方面，\n只有收到些许成果。", stat_desc)), teacher);
					break;
				case 3://成果无
					teacher_say = { pk::format("虽投下心力指导，\n却得不到\x1b[02x{}\x1b[0x的学习成果。",stat_desc),
					pk::format("真是可惜！\n\x1b[02x{}\x1b[0x的学习成果不佳。",stat_desc),
					pk::format("到底是那里出了差错？\n得不到任何\x1b[02x{}\x1b[0x的学习成果。",stat_desc)
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					break;
				default:
					break;
				}

				show_stat_report = false;
				info_stat_report = "";
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("属下将严格指导\x1b[01x{}\x1b[0x，\n期使他早日成为堂堂的武将。", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("让我们拭目以待\x1b[01x{}\x1b[0x今后的表现吧！", talent_name)), teacher);


			}

		}

		void 事件_小兵培训结束()
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			if (force_t.remained_time == 0 and !force_t.is_out)// and !force_t.time_extended & 2 == 0)
			{
				pk::person@ talent = pk::get_person(force_t.talent_id);

				pk::person@ teacher = pk::get_person(force_t.teacher_id);

				if (pk::is_alive(teacher))
				{
					pk::trace("事件_小兵培训结束 remained_time" + force_t.remained_time);
					string talent_name = pk::decode(talent.sei + talent.mei);
					string teacher_name = pk::decode(pk::get_name(teacher));
					pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的指导结束了。", talent_name)));
					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("对\x1b[01x{}\x1b[0x的指导工作就此完成。", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的指导就此完整告一段落。", talent_name)), teacher);

					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n在这次的训练中，\n你有何感想？", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n在这次的训练中，\n你感受到什么？", talent_name)), teacher);

					pk::rand_bool(50) ? pk::message_box(pk::encode("多亏您的关照，\n我才能成为独当一面的武将，\n真要感谢您。"), talent) : pk::message_box(pk::encode(pk::format("多亏有\x1b[01x{}\x1b[0x大人的指导，\n才有现在的成果，\n不知如何感谢才好。", teacher_name)), talent);
					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x啊！\n期待你今后的表现喔。", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n希望今后你能大展长才。", talent_name)), teacher);

					//设置列传，设置小兵加入我军，显示小兵信息窗

					init_belong(talent, pk::get_building(teacher.service), true, 身份_一般, 100, 1000);
					new_person::limit_skill_set(talent,10);//根据小兵能力重设特技
					pk::call_find_window(talent,2);//改版的发现人才窗口
					force_t.init_talent_info();
				}
			}
		}

		void 小兵培养事件(int event_id)
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			pk::force@ force = pk::get_force(force_id);
			pk::person@ kunshu = pk::get_person(force.kunshu);
			string kunshu_name = pk::decode(pk::get_name(kunshu));
			pk::person@ talent = pk::get_person(force_t.talent_id);
			string talent_name = pk::decode(talent.sei + talent.mei);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			string teacher_name = pk::decode(pk::get_name(teacher));

			array<string> talent_say;
			array<string> teacher_say;
			pk::list<pk::person@> person_list;
			bool 近期对抗发生 = false;
			//是否需要判断小兵和教师id有效
			switch (event_id)
			{
			case 小兵事件_精进1:
			case 小兵事件_精进2:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x是怎么了？\n最近的企图心令人刮目相看。", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x修行时的神情，\n一改往常，充满活力。", talent_name)), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("(对\x1b[01x{}\x1b[0x大人你的仰慕之情\n改变了我整个人，\n努力想使自己和你并驾齐驱。)", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("(对\x1b[01x{}\x1b[0x大人你的仰慕之情\n是我力量的泉源。)", teacher_name)), talent);
				//音效
				pk::play_se(6);//差结果是7
				force_t.talent_status = 0;//数字越大，疲劳度越大，各种训练效果差
				set_event_happened(force_t, 小兵事件_精进2);
				add_event_ability(force_t,talent, 小兵事件_精进2);
				break;
			case 小兵事件_思慕:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，怎么了？\n总是看来闷闷不乐的样子，\n该不会是身体有所不适？", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，怎么了？\n总是连连叹气，\n莫非碰到什么事？", talent_name)), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("(思慕\x1b[01x{}\x1b[0x大人过度，\n令我无心修行……。)", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("(实在无法对\x1b[01x{}\x1b[0x大人\n吐露自己的仰慕之情。)", teacher_name)), talent);
				//音效
				pk::play_se(7);//差结果是7
				force_t.talent_status = 4;//数字越大，疲劳度越大，各种训练效果差
				set_event_happened(force_t, 小兵事件_思慕);
				add_event_ability(force_t, talent, 小兵事件_思慕);
				break;
			case 小兵事件_不和:
				teacher_say = { pk::format("\x1b[01x{}\x1b[0x，\n为何不照我所说的练习呢？",talent_name),
				pk::format("\x1b[01x{}\x1b[0x，\n我都教了这么多了，\n你还不了解吗？！",talent_name),
				pk::format("\x1b[01x{}\x1b[0x，\n为何不照我所说的练习呢？\n有什么怨言的话就说出来！",talent_name)
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人所说的，\n我觉得未必正确。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("我对\x1b[01x{}\x1b[0x大人的教法存有疑问。)", teacher_name)), talent);
				//需要一个比较老师和学生差距的函数，然后得出结果，而且不应该允许学生差一些也能胜利---TODO
				//bool compare_result = true;
				if (get_rand_int(talent.base_stat[武将能力_统率], 100) >= 50)
				{
					//老师胜利
					teacher_say = { "毛头小子竟敢说大话，\n等到有能力独当一面后，\n再说也不晚吧！",
						"你还未成器，\n就学会顶嘴？\n别自以为是！",
						"你既然这么说的话，\n那就将成果亮出来看看！"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					pk::rand_bool(50) ? pk::message_box(pk::encode("何必说那般伤人的话……，\n我已渐失修行之心了。"), talent) : pk::message_box(pk::encode("……\n我是为何而修行呢？！"), talent);
					force_t.talent_status = 4;//数字越大，疲劳度越大，各种训练效果差
				}
				else
				{
					//学生胜利
					teacher_say = { "毛头小子竟敢说大话，\n等到有能力独当一面后，\n再说也不晚吧！",
					"你还未成器，\n就学会顶嘴？\n别自以为是！",
					"你既然这么说的话，\n那就将成果亮出来看看！"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					pk::message_box(pk::encode(pk::format("不仰赖\x1b[01x{}\x1b[0x大人，\n我也能独力完成修行！)", teacher_name)), talent);
					force_t.talent_status = 0;
				}


				//音效
				pk::play_se(7);//差结果是7
				force_t.talent_status = 4;//数字越大，疲劳度越大，各种训练效果差
				set_event_happened(force_t, 小兵事件_不和);
				add_event_ability(force_t, talent, 小兵事件_不和);
				break;
			case 小兵事件_生病:
				/*
			中途要求更换指导者。
			中途与指导者发生对立。
			中途与指导者有口舌争端。
			中途出走，拒绝特别训练。
			中途流浪旅行。
			中途返乡探亲。
			中途罹患疾病。
				*/
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，对不起……，\n我好像发烧的样子，\n头晕目眩……。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，对不起……，\n我感到呼吸困难，\n现在也快要晕倒了……。", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x啊，这时候要好好休养调适。\n要是把身体搞坏了，\n可是什么事都做不了了。", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("不要逞强，\x1b[01x{}\x1b[0x，\n应好好调适休养。\n修行随时都能做。", talent_name)), teacher);
				//音效
				pk::play_se(7);//差结果是7
				force_t.talent_status = 3;//数字越大，疲劳度越大，各种训练效果差
				set_event_happened(force_t, 小兵事件_生病);
				add_event_ability(force_t, talent, 小兵事件_生病);
				break;
			case 小兵事件_延长修行:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n你的修行只完成一半，\n不能就此结束。", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n你还有可训练的余地。", talent_name)), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("为了不让你往后心存悔憾，\n要再多修行一会吗？"), teacher) : pk::message_box(pk::encode(pk::format("我决心让\x1b[01x{}\x1b[0x你好好完成训练，\n希望你能继续练习。", talent_name)), teacher);

				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("那就拜托大人了，\n只要能提升自己的能力，\n多努力点是应该的。", teacher_name)), talent) : pk::message_box(pk::encode("我也正想请求大人帮忙，\n我会拚命修行。"), talent);
				//音效
				pk::play_se(6);//差结果是7
				force_t.remained_time += 3;
				force_t.time_extended = true;
				set_event_happened(force_t, 小兵事件_延长修行);
				add_event_ability(force_t, talent, 小兵事件_延长修行);
				break;
			case 小兵事件_学生更换老师1:
			case 小兵事件_学生更换老师2:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n有事想请你答应，\n我想在其它师父的门下学习。", kunshu_name)), talent) : pk::message_box(pk::encode("实在很对不起，\n可否让我拜其它人为师呢？"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("我已任命\x1b[01x{}\x1b[0x做你的师傅，\n你对他是否有所不满？。", teacher_name)), kunshu) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的教授方式\n还挺不错的……\n到底是哪里不好？", teacher_name)), kunshu);
				pk::rand_bool(50) ? pk::message_box(pk::encode("请您别误解！\n我为了加深自身的见识，\n才想跟随多位师父学习钻研。"), talent) : pk::message_box(pk::encode("请您别误会！\n我只是想向多人学习讨教。"), talent);

				近期对抗发生 = get_recent_event_id(force_t) == 小兵事件_对抗;
				if (近期对抗发生 or (pk::get_aishou_distance(talent, force.kunshu) < pk::get_aishou_distance(teacher, force.kunshu) and get_rand_int(talent.base_stat[武将能力_统率], 100) < 50))//根据能力等判断发生哪个事件
				{
					pk::message_box(pk::encode(pk::format("……好吧。\n我就指派下任的指导武将吧！想必\x1b[01x{}\x1b[0x会感到难过吧！", teacher_name)), kunshu);
					//展示选择武将列表--排除原来的师傅
					//此处会卡住
					person_list.clear();
					for (int i = 0; i < 非贼武将_末; ++i)
					{
						if (i == int(force_t.teacher_id)) continue;
						pk::person@ person = pk::get_person(i);
						if (pk::is_alive(person) and pk::check_mibun(person, pk::mibun_flags(身份_君主, 身份_都督, 身份_太守, 身份_一般)) and person.get_force_id() == force_id)
							person_list.add(person);
					}
					set_teacher(force_id, person_list, false, talent_name);
					set_event_happened(force_t, 小兵事件_学生更换老师1);
					add_event_ability(force_t, talent, 小兵事件_学生更换老师1);
				}
				else {
					teacher_say = { "不好好反省自己的不成器，\n还敢开口要求，\n真是无可容忍！",
					"这个不成材的家伙！\n用这种想法就想完成修行吗？",
					"不明白自己的立场，\n还说此大话……？\n再重新来过！",
					"具有独当一面的能力后，\n再说那话也不迟！"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), kunshu);
					pk::rand_bool(50) ? pk::message_box(pk::encode("对不起，\n我会重新修行的。"), talent) : pk::message_box(pk::encode("我太不自量力了，\n对不起。"), talent);
					//pk::play_se(7);
					set_event_happened(force_t, 小兵事件_学生更换老师2);
					add_event_ability(force_t, talent, 小兵事件_学生更换老师2);
				}

				break;
			case 小兵事件_老师更换老师:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("深感自身能力的不足，\n我无法继续指导\x1b[01x{}\x1b[0x。", talent_name)), teacher) : pk::message_box(pk::encode("我不够能力教导他人，\n请求您撤消这项任务。"), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("说什么话！\n你有十足的能力，\n再考虑考虑吧。"), kunshu) : pk::message_box(pk::encode("好不容易有点成果了，\n你不再重新考虑吗？"), kunshu);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("由我这个生手来指导，\n对\x1b[01x{}\x1b[0x来说，\n有点可怜。", talent_name)), teacher) : pk::message_box(pk::encode("找个比我更合适的人选吧！！"), teacher);
				pk::message_box(pk::encode("……，\n没办法，\n只好决定下一任指导武将吧！"), kunshu);
				//展示选择武将列表--排除原来的师傅

				for (int i = 0; i < 非贼武将_末; ++i)
				{
					if (i == int(force_t.teacher_id)) continue;
					pk::person@ person = pk::get_person(i);
					if (pk::is_alive(person) and pk::check_mibun(person, pk::mibun_flags(身份_君主, 身份_都督, 身份_太守, 身份_一般)) and person.get_force_id() == force_id)
						person_list.add(person);
				}
				set_teacher(force_id, person_list, false, talent_name);
				set_event_happened(force_t, 小兵事件_老师更换老师);
				add_event_ability(force_t, talent, 小兵事件_老师更换老师);
				break;
			case 小兵事件_学生出走1:
			case 小兵事件_学生出走2:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("启禀大人，\n我已跟不上\x1b[01x{}\x1b[0x大人的指导了。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("我再也无法跟随\x1b[01x{}\x1b[0x大人修行了。", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("先冷静一下，\n怎能如此轻言放弃？"), teacher) : pk::message_box(pk::encode("凡事皆有不完美之处，\n忍耐也是修行之一。"), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人的做法\n太自我中心了，\n总是随意决定行事。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("我和\x1b[01x{}\x1b[0x大人个性不合，\n不论做什么，\n总是感到心力交瘁……。", teacher_name)), talent);

				//计算老师的属性相关值是否大于相性带来的影响--TODO
				if (pk::get_aishou_distance(teacher, force_t.talent_id) <= get_rand_int(talent.base_stat[武将能力_统率], 100))
				{
					pk::rand_bool(50) ? pk::message_box(pk::encode("我的做法似乎太过强硬，\n今后会加以改进。"), teacher) : pk::message_box(pk::encode("我似乎对你要求太过份，\n我会重新检讨的。"), teacher);
					pk::play_se(6);
					set_event_happened(force_t, 小兵事件_学生出走2);
					add_event_ability(force_t, talent, 小兵事件_学生出走2);

				}
				else
				{
					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("承蒙\x1b[01x{}\x1b[0x大人至今的多方关照，\n就请忘了我这个人。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("我将和\x1b[01x{}\x1b[0x分别了，\n请不要打听我的下落。", teacher_name)), talent);
					pk::play_se(7);
					talent_leave_event(force_id, force_t, 小兵事件_学生出走1, talent_name);
					set_event_happened(force_t, 小兵事件_学生出走1);
					add_event_ability(force_t, talent, 小兵事件_学生出走1);
				}
				break;
			case 小兵事件_返乡探亲:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n我老家的父亲病倒了，\n我想回去照顾父亲。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，老家遇上灾害，可否让我回去探视？", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("确实令人担心哪，\n修行随时可练，\n你还是回去一趟比较好。"), teacher) : pk::message_box(pk::encode("那真是不得了了。\n你快回去一趟。"), teacher);
				pk::message_box(pk::encode("感谢您。\n我会尽早赶回来的。"), talent);


				talent_leave_event(force_id, force_t, 小兵事件_返乡探亲, talent_name);
				set_event_happened(force_t, 小兵事件_返乡探亲);
				add_event_ability(force_t, talent, 小兵事件_返乡探亲);
				break;
			case 小兵事件_流浪旅行1:
			case 小兵事件_流浪旅行2:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n可否容许我暂时出外旅行？", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n请容许我暂时离开此地，\n见识诸方风物。", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("你说这是什么话？！"), teacher) : pk::message_box(pk::encode("你有什么不满吗？！"), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("在修行途中，\n我领悟到我真正缺乏的是见识。"), talent) : pk::message_box(pk::encode("为了突破自己能力上的瓶颈，\n我决心要多看看外面的世界。"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("现在就此放弃的话，\n你历经过的辛劳\n就会变得毫无意义了。"), teacher) : pk::message_box(pk::encode("现在就离开的话，\n至今的修行\n可会变得徒劳无功唷。"), teacher);
				//temp = (_DWORD*)(5 * *(_DWORD*)info->unknown2);
				//v91 = stat_compare_4084A0(a1, 100, info);
				//  if ( v91 >= (int)temp )
				if (get_rand_int(talent.base_stat[武将能力_统率], 100) > 5 * talent.giri)//
				{
					pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n请原谅我的任性！", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n我绝对不会枉费至今的成果的。", teacher_name)), talent);
					teacher_say = { "……好吧，\n就随你高兴。",
						"好吧……。\n若是途中遭遇艰难，\n就回想这段修行的日子吧。",
						"……我明白了，\n就照你的意思去做吧！",
						"……好吧，\n照你的想法去做吧！"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					pk::play_se(7);
					talent_leave_event(force_id, force_t, 小兵事件_流浪旅行1, talent_name);
					set_event_happened(force_t, 小兵事件_流浪旅行1);
					add_event_ability(force_t, talent, 小兵事件_流浪旅行1);
				}
				else
				{
					pk::rand_bool(50) ? pk::message_box(pk::encode("你忘了我们曾发誓\n要共同奋战以结束乱世吗？"), teacher) : pk::message_box(pk::encode("一旦就此逃避后，\n你可会终生后悔的！"), teacher);
					pk::rand_bool(50) ? pk::message_box(pk::encode("……对不起，我错了，\n请好好地锻练我吧！"), talent) : pk::message_box(pk::encode("现在大人的这番话点醒了我，\n我将会朝向更高的目标努力。"), talent);
					pk::play_se(6);
					set_event_happened(force_t, 小兵事件_流浪旅行2);
					add_event_ability(force_t, talent, 小兵事件_流浪旅行2);
				}

				break;
			case 小兵事件_对抗:
				//40 42 43 /45 47/48 49 51/52 54/
				teacher_say = { pk::format("\x1b[01x{}\x1b[0x，\n你心不在焉，\n真有心修行吗？",talent_name),
				"你那是什么眼神……？\n难道对我的做法有所不满吗？",
				pk::format("喂！\x1b[01x{}\x1b[0x！\n你是不是在敷衍？！",talent_name),
				pk::format("\x1b[01x{}\x1b[0x！\n你要我说几遍同样的话？！",talent_name)
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("我是什么地方做不好？\n我可是尽心尽力在修行。"), talent) : pk::message_box(pk::encode("我自认为是很努力地修行，\n你那种说法未免太……。"), talent);
				teacher_say = { "什么话！\n以那种方式就想修行成功吗？",
					"你说什么！\n若是无心修行，\n就明说吧。",
					"要说些幼稚的话！\n若是无心修行，\n就明说吧。",
					"住口！\n你不要以这幼稚的想法来修行。"
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				//此处应该加一段动画，以展现对决---TODO
				if (2 * teacher.stat[武将能力_统率] < talent.base_stat[武将能力_统率])//talent已远远青出于蓝
				{
					teacher_say = { "唔……。\n不要以为我会就此作罢！",
						"呜…！\n不要以三脚猫的实力感到自豪！",
						"好痛……。\n想和我做对，\n给我记住！",
						"可恶，\n竟以修行之身殴打师父……，\n好大胆！"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					pk::rand_bool(50) ? pk::message_box(pk::encode("不要认为什么事都是你对！"), talent) : pk::message_box(pk::encode("我也有所觉悟，\n随时等候赐教。"), talent);
					set_event_happened(force_t, 小兵事件_对抗);
					add_event_ability(force_t, talent, 小兵事件_对抗);
					//TODO--事件的效果
					//v113 = min(person_46A0D0->disliked[0] + 1, 7);
					//talant_stat_inc_44F040(person_46A0D0, v113, 1);
				}
				else if (teacher.stat[武将能力_统率] > talent.base_stat[武将能力_统率])//teahcer尚能压制talent
				{
					pk::message_box(pk::encode("呜……。"), talent);
					teacher_say = { "此痛将会鞭策你继续修行！",
						"看清楚了吗！\n这就是实力的天壤之别。",
						"如此一来，\n该多少认清点事实了吧！",
						"要知道天有多高地有多厚。"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					pk::rand_bool(50) ? pk::message_box(pk::encode("你大可这般自豪下去，\n我对你已感到失望了。"), talent) : pk::message_box(pk::encode("可恶……。\n为何我会这么倒霉……。"), talent);
					set_event_happened(force_t, 小兵事件_对抗);
					add_event_ability(force_t, talent, 小兵事件_对抗);
					//inc_value = min(*(_DWORD *)&info->unknown2[16] + 1, 7);
					//talant_stat_inc_44F040(info, inc_value, 1);
				}
				else//talent超过teacher,但未远超
				{
					teacher_say = { "今日就放你一马！",
						"你要以此作为教训，\n今后要谨言慎行！",
						"下次若再违抗的话，\n就不轻易饶你！！",
						"因为从今以后也要严格训练，\n你要有心理准备！"
					};
					pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
					pk::rand_bool(50) ? pk::message_box(pk::encode("你该好好反省反省自己了。"), talent) : pk::message_box(pk::encode("你不会设身处地为他人着想吗？"), talent);
					set_event_happened(force_t, 小兵事件_对抗);
					add_event_ability(force_t, talent, 小兵事件_对抗);
				}
				break;
			case 小兵事件_老师能力好:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人的教导非常合理，\n真是浅显易懂。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("不愧为\x1b[01x{}\x1b[0x大人的传授，\n条理分明，\n易于理解。", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("听你如此说来，\n真是不枉费我苦心传授你。"), teacher) : pk::message_box(pk::encode("有你这句话，\n真是让我倍感欣慰。"), teacher);

				talent_status_release(force_t);
				add_event_ability(force_t, talent, 小兵事件_老师能力好);
				break;
			case 小兵事件_老师能力差:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人的教法艰深难懂，\n恕在下不才无法跟上学习进度。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("说实在的，\n有时真的不懂\x1b[01x{}\x1b[0x大人的教导。", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("我这么仔细教你，\n你居然还不懂……。"), teacher) : pk::message_box(pk::encode("在我这般用心教授之下，\n居然还不了解……。"), teacher);

				force_t.talent_status += 1;
				add_event_ability(force_t, talent, 小兵事件_老师能力差);
				break;
			case 小兵事件_师生相性好:
				teacher_say = { pk::format("\x1b[01x{}\x1b[0x啊！\n修炼之道可说是永无止境，\n相信我的教授就能精进。",talent_name),
				pk::format("\x1b[01x{}\x1b[0x啊！\n不断磨练自己，\n方能成为有能之士，\n切莫半途而废啊！",talent_name),
				pk::format("\x1b[01x{}\x1b[0x啊！\n你的资质够好，\n更要坚持不懈地努力才行。",talent_name)//锲而不舍的锲无法编码，换个词
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("感谢您的勉励。\n我会以此日日鞭策自己，\n以不辜负您的期望。"), talent) : pk::message_box(pk::encode("此番良言我已铭记在心，\n我会比现在更加用心修行。"), talent);

				talent_status_release(force_t);
				add_event_ability(force_t, talent, 小兵事件_师生相性好);
				break;
			case 小兵事件_师生相性差:
				teacher_say = { pk::format("\x1b[01x{}\x1b[0x啊！\n若是继续停滞于现状，\n今后是不会有进展的。",talent_name),
					"还要多加努力！\n你下的功夫还不够。",
				pk::format("\x1b[01x{}\x1b[0x！\n同样的话要我再说几次，\n给我聚精会神，认真修行！",talent_name),
				"还不行！\n再多加把劲！。"
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("抱歉，\n我已尽我所能……。"), talent) : pk::message_box(pk::encode("我已在努力学习中……。"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("别睁眼说瞎话，\n还不赶快修行！"), teacher) : pk::message_box(pk::encode("我不想听你的辩解，\n真是没见过像你这般的人。"), teacher);
				force_t.talent_status += 1;
				add_event_ability(force_t, talent, 小兵事件_师生相性差);
				break;
			case 小兵事件_学习进度好:
				pk::rand_bool(50) ? pk::message_box(pk::encode("你若是如此修行下去，\n再假以时日，\n连我都可能会输给你唷！"), teacher) : pk::message_box(pk::encode("这般日益精进之下，\n要超越我也是迟早的问题。"), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("我的经验还不够，\n今后还继续追随\x1b[01x{}\x1b[0x大人，\n以求修行更上层楼。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("您过奖了，\n和\x1b[01x{}\x1b[0x大人的实力差距，\n还有好一大截呢。", teacher_name)), talent);
				talent_status_release(force_t);
				add_event_ability(force_t, talent, 小兵事件_学习进度好);
				break;
			case 小兵事件_学习进度差:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n不管如何练习，\n总觉得对自己毫无自信。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n我真的能够完成修行吗？", teacher_name)), talent);

				pk::rand_bool(50) ? pk::message_box(pk::encode("不用焦急，\n即使你一时之间感觉不到，\n不过你可是着实在进步中唷。"), teacher) : pk::message_box(pk::encode("对自己要有信心，\n不间断地持续修行，\n必定能学成。"), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("无论再怎么努力练习，\n就是无法追上\x1b[01x{}\x1b[0x大人。", teacher_name)), talent) : pk::message_box(pk::encode("不论如何练习，\n总觉得成功的希望渺茫。"), talent);

				force_t.talent_status += 1;
				add_event_ability(force_t, talent, 小兵事件_学习进度差);
				break;
			case 小兵事件_迎难而上:
				teacher_say = { pk::format("\x1b[01x{}\x1b[0x，\n光这样还不行，\n看来修行之路还长哩！",talent_name),
				 pk::format("\x1b[01x{}\x1b[0x，\n喊累还太早了，\n现在才刚开始呢！",talent_name),
				pk::format("\x1b[01x{}\x1b[0x，\n修行还不够，\n重新再来。",talent_name)
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("纵使修行之路艰困，\n我也会交出成果给你看的。"), talent) : pk::message_box(pk::encode("我不会就此气馁的！"), talent);
				talent_status_release(force_t);
				add_event_ability(force_t, talent, 小兵事件_迎难而上);
				break;
			case 小兵事件_知难而退:
				teacher_say = { pk::format("\x1b[01x{}\x1b[0x，\n你的实力就这么点儿吗？\n真是没用",talent_name),
				pk::format("\x1b[01x{}\x1b[0x，\n你可以表现得更好才对！\n为何就此松懈？",talent_name),
				pk::format("\x1b[01x{}\x1b[0x，\n你更努力修行才行！\n真是丢人现眼！",talent_name)
				};
				pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
				pk::rand_bool(50) ? pk::message_box(pk::encode("即使这么努力，\n也修行不成吗…？\n或许我的能力真的不够。"), talent) : pk::message_box(pk::encode("不管怎么努力也不成功，\n我已丧失了自信。"), talent);

				force_t.talent_status += 1;
				add_event_ability(force_t, talent, 小兵事件_知难而退);
				break;
			case 小兵事件_生病2:
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，我感觉有点不适。\n即使有心想修行，\n但身体跟不上来……。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人，\n我身体提不起劲，\n总觉得很恶心……。", teacher_name)), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("不要逞强，\n有健康的身体才能修行，\n适时地停手吧！"), teacher) : pk::message_box(pk::encode("太过逞强的话，\n修行也可能会有反效果。\n我看就适可而止吧。"), teacher);

				force_t.talent_status += 1;
				add_event_ability(force_t, talent, 小兵事件_生病2);
				break;
			case 小兵事件_恢复:
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n身体状况如何了？", talent_name)), teacher);
				pk::message_box(pk::encode("托您的福，\n身体已经恢复得差不多了。"), talent);
				talent_status_release(force_t);
				add_event_ability(force_t, talent, 小兵事件_恢复);
				break;
			case 小兵事件_兵法常规:
				scen_小兵兵法培养();//scene里面无法再调用scene
				break;
			case 小兵事件_兵法领悟:
				scen_小兵领悟兵法();//pk::scene(pk::scene_t(scen_小兵领悟兵法));
				break;
			case 小兵事件_兵法3:
				scen_小兵兵法培养2();// pk::scene(pk::scene_t(scen_小兵兵法培养2));
				break;
			default:
				break;
			}
		}

		void set_event_happened(forceinfo@ force_t, int id)
		{
			ch::set_bit(force_t.train_event, id, true);
			//按序设定发生过的事件，超过3个了，就不设定了
			for (int i = 0; i < 3; ++i)
			{
				if (force_t.recent_special_event[i] == 0)
				{
					force_t.recent_special_event[i] = id;
					break;
				}
			}
			return;
		} 

		int get_recent_event_id(forceinfo@ force_t)
		{
			for (int i = 2; i > -1; --i)
			{
				int value = force_t.recent_special_event[i];
				if (value >0 and value <= 小兵事件_兵法3)
				{
					return value;
				}
			}
			return 0;
		}

		int cal_special_event_count(forceinfo@ force_t)
		{
			int count = 0;
			for (int i = 0; i < 3; ++i)
			{
				int value = force_t.recent_special_event[i];
				if (value > 0 and value <= 小兵事件_兵法3)
				{
					count += 1;
				}
			}
			return count;
		}

		int get_upgrade_heishu_count(pk::person@ person, int heishu_id, int heishu_max = 适性_S)
		{
			int count = heishu_max - person.tekisei[heishu_id];
			if (count < 0) count = 0;
			return count;
		}

		int get_all_upgrade_heishu_count(pk::person@ person, int heishu_max = 适性_S)
		{
			//c到s有3级可升，总共6种兵种，18级
			int count = 0;
			for (int i = 0; i < 兵种_末; ++i)
			{
				count += get_upgrade_heishu_count(person, i , heishu_max);
			}
			return count;
		}

		int get_heishu_diff(pk::person@ teacher, pk::person@ talent, int heishu_id)
		{
			int diff = teacher.tekisei[heishu_id] - talent.tekisei[heishu_id];
			if (diff < 0) diff = 0;
			return diff;
		}

		int get_stat_diff(pk::person@ teacher, pk::person@ talent, int stat_type)
		{
			int diff = teacher.stat[stat_type] - talent.base_stat[stat_type];
			return diff;
		}

		int get_all_stat_diff(pk::person@ teacher, pk::person@ talent)
		{
			int diff = 0;
			for (int i = 0; i < 武将能力_末; ++i)
			{
				diff += teacher.stat[i] - talent.base_stat[i];
			}
			return diff;
		}

		float get_all_stat_diff_eff(pk::person@ teacher, pk::person@ talent, int id)
		{
			float diff = 0;
			int sum = 0;
			for (int i = 0; i < 武将能力_末; ++i)
			{
				diff += (teacher.stat[i] - talent.base_stat[i]) * 训练项目收益[id][i];
				sum += 训练项目收益[id][i];
			}
			diff = diff / sum;
			return diff;
		}

		float get_all_stat_eff(pk::person@ person, int id)
		{
			float diff = 0;
			int sum = 0;
			for (int i = 0; i < 武将能力_末; ++i)
			{
				diff += person.base_stat[i] * 训练项目收益[id][i];
				sum += 训练项目收益[id][i];
			}
			diff = diff / sum;
			return diff;
		}

		float get_all_zhizi_eff(forceinfo@ force_t, int id)
		{
			float eff = 0;
			int sum = 0;
			for (int i = 0; i < 武将能力_末; ++i)
			{
				eff += force_t.max_stat[i] * 训练项目收益[id][i];
				sum += 训练项目收益[id][i];
			}
			eff = eff / sum;
			return eff;
		}
		//计算如何能学得兵法？师傅对应能力适性buf,武将对应能力适性buf,高难度兵法负面buf
		//还有成功失败的情况，高级兵法s需要徒弟需要相对高的能力
		int get_tactic_study_reusult(forceinfo@ force_t, pk::person@ teacher, pk::person@ talent, int id,bool fatigue = false)
		{
			//兵法学习的情况

				//TODO学习效果，能力变化，适性变化，特殊功绩特技习得？
				//失败分4种 根据老师会不会，学生领悟能力好不好，分为4种
				//成功分2种 学得很好， 学得一般
				//0老师不会,学生领悟差
				//1老师会，学生领悟差
				//2老师会，学生领悟好
				//3老师不会，学生领悟好
				//4普通学会
				//5超常发挥
				//基础失败率20，资质，能力，能力差影响失败率，如果发生失败，那根据能力判断时哪种情况
			float basic_failure_rate = 20.0f + (fatigue ? 10 : 0);
			float heishu_eff = (id < 武将能力_末) ? 0 : get_heishu_diff(teacher, talent, id-武将能力_末) * 5.0f;
			//能力经验也意味着对应能力占比？
			float stat_diff_eff = get_all_stat_diff_eff(teacher, talent, id) * 0.2f;//50左右？可能只有20-10？

			float talent_zhizi_eff = (get_all_zhizi_eff(force_t, id) - 70) * 0.2f;//资质决定悟性

			int failure_rate = int(basic_failure_rate - heishu_eff - stat_diff_eff - talent_zhizi_eff);
			float talent_stat_eff = get_all_stat_eff(talent, id);
			float teacher_stat_eff = get_all_stat_eff(teacher, id);
			//失败的情况
			if (pk::rand_bool(failure_rate))
			{
				if (heishu_eff < 0 or teacher_stat_eff < 70)//老师不会的情况
				{
					if (talent_stat_eff < 60 or talent_zhizi_eff < 75)
					{
						return 0;//0老师不会,学生领悟差
					}
					else
					{
						return 3;//3老师不会，学生领悟好
					}
				}
				else
				{
					if (talent_stat_eff < 60 or talent_zhizi_eff < 75)
					{
						return 1;//1老师会，学生领悟差
					}
					else
					{
						return 2;//2老师会，学生领悟好
					}
				}
			}
			else
			{
				//超常发挥应该要根据学生能力，老师能力，能力差等因素，概率触发？
				if (force_t.talent_status < 2)
				{
					if (heishu_eff > 0 or teacher_stat_eff > 70 or talent_zhizi_eff > 75)
					{
						int rate = 5 + int(heishu_eff + stat_diff_eff + pk::max(talent_zhizi_eff - 70, talent_stat_eff - 60) + (talent_stat_eff - 70)) / 10;
						if (pk::rand_bool(rate))
						{
							return 5;
						}
					}
				}

				//普通学会兵法放最后，排除其他情况就是普通了
				return 4;
			}

		}

		array<int> get_unavailable_num(pk::person@ talent)
		{
			array<int> arr;
			//当对应适性满时，不能选择培养对应适性？
			for (int i = 0; i < 适性_末; ++i)
			{
				if (talent.tekisei[i] >= 适性_S)
				{
					arr.insertLast(i+武将能力_末);
				}
			}
			return arr;
		}

		string add_ability(forceinfo@ force_t, pk::person@ person, int result, int id)
		{
			string desc = "";
			float rate = (result == 5) ? 1.5f : (result == 4) ? 1.0f : 0.30f;
			for (int i = 0; i < 武将能力_末;++i)
			{
				int inc = int(训练项目收益[id][i] * rate);
				int max_inc = pk::min((force_t.max_stat[i] - person.base_stat[i]) * 100, inc);//确保增加能力不会超过对应能力上限
				add_stat_exp(person, i, max_inc);
			}
			int pre_tekisei = 0;
			int count = 0;
			for (int i = 0; i < 兵种_末;++i)
			{
				if (person.tekisei[i] >= 适性_S) continue;//限制适性s以后的经验增长
				pre_tekisei = person.tekisei[i];
				add_heishu_exp(person, i, int(训练项目收益[id][i+ 武将能力_末] * rate));
				if (person.tekisei[i] - pre_tekisei > 0)
				{
					desc += ((count > 0?",":"") + 兵种名[i]);
					count += 1;
				}
			}
			return desc;
		}

		void add_event_ability(forceinfo@ force_t, pk::person@ person, int event_id)
		{
			for (int i = 0; i < 武将能力_末; ++i)
			{
				int inc = 事件基础收益[event_id][i];
				int max_inc = pk::min((force_t.max_stat[i] - person.base_stat[i]) * 100, inc);//确保增加能力不会超过对应能力上限
				add_stat_exp(person, i, max_inc);
			}
		}

		void add_stat_exp(pk::person@ person, int type, int value)
		{
			//游戏原函数对未登场武将不起效，重写一个
			int inc = (value + person.stat_exp[type])/100;
			int mod = (value + person.stat_exp[type])% 100;
			person.base_stat[type] = inc + person.base_stat[type];
			person.stat_exp[type] = mod;
			return;
		}

		void add_heishu_exp(pk::person@ person, int type, int value)
		{
			//游戏原函数对未登场武将不起效，重写一个
			int inc = (value + person.heishu_exp[type]) / 250;
			int mod = (value + person.heishu_exp[type]) % 250;
			person.tekisei[type] = inc + person.tekisei[type];
			person.heishu_exp[type] = mod;
			return;
		}

		int get_negtive_event_count(forceinfo@ force_t)
		{
			int count = 0;
			//if (ch::test_bit(force_t.train_event, 小兵事件_对抗)) count += 1;
			if (ch::test_bit(force_t.train_event, 小兵事件_不和)) count += 1;
			if (ch::test_bit(force_t.train_event, 小兵事件_师生相性差)) count += 1;
			if (ch::test_bit(force_t.train_event, 小兵事件_学习进度差)) count += 1;
			if (ch::test_bit(force_t.train_event, 小兵事件_老师能力差)) count += 1;
			return count;
		}

		bool check_talent_out_event(forceinfo@ force_t)
		{
			//探亲居然不算
			if (ch::test_bit(force_t.train_event, 小兵事件_流浪旅行1)) return true;
			if (ch::test_bit(force_t.train_event, 小兵事件_流浪旅行2)) return true;
			if (ch::test_bit(force_t.train_event, 小兵事件_学生出走1)) return true;
			if (ch::test_bit(force_t.train_event, 小兵事件_学生出走2)) return true;
			return false;
		}

		int get_auto_learn_rate(pk::person@ talent)
		{
			return 0;
		}

		void set_teacher(int force_id, pk::list<pk::person@>list, bool first_time, string talent_name)
		{
			auto force_t = ch::get_force_p(force_id);
			pk::person@ kunshu = pk::get_person(pk::get_force(force_id).kunshu);
			string kunshu_name = pk::decode(pk::get_name(kunshu));

			pk::list<pk::person@> person_sel;
			do
			{
				person_sel = pk::person_selector(pk::encode("指导武将选择"), pk::encode(pk::format("选择{}的指导武将.", talent_name)), list, 1, 1);
			} while (person_sel.count == 0 or list.count == 0);
			pk::person@teacher = @person_sel[0];
			string teacher_name = pk::decode(pk::get_name(teacher));
			force_t.teacher_id = teacher.get_id();

			//选择指导方针---严格，均衡，躬亲-----
			array<string> answers =
			{
				pk::encode("严格"),
				pk::encode("均衡"),
				pk::encode("躬亲")
			};

			int confirm_value = pk::choose(pk::encode(pk::format("请选择\x1b[01x{}\x1b[0x的指导方针。\n(严格：专注能力，均衡：平衡能力适性，躬亲：专注兵法)", talent_name)), answers);
			force_t.teaching_method = confirm_value;

			/*
			交由{}担任{}的指导吧！
			由我亲自指导{}吧！

			此事交由我来办。我会尽我所能，使其成为独当一面的武将。
			我打算着实培养此人，使其成为我军的主力人材。
			*/
			if (kunshu.get_id() != teacher.get_id())
			{
				pk::message_box(pk::encode(pk::format("那便交由\x1b[01x{}\x1b[0x担任\x1b[02x{}\x1b[0x的指导吧！", teacher_name, talent_name)), kunshu);
				pk::message_box(pk::encode("此事交由我来办。我会尽我所能，使其成为独当一面的武将。"), teacher);
			}
			else
			{
				pk::message_box(pk::encode(pk::format("那么就由我来培养\x1b[01x{}\x1b[0x吧。", talent_name)), teacher);
				pk::message_box(pk::encode("我打算着实培养此人，\n使其成为我军的主力人才。"), teacher);
			}

			//还有个不明用途的，将talent_status设置为1或2的动作

			if (first_time) force_t.remained_time = 9;//第一次时，将培养时间设为9
		}

		void talent_leave_event(int force_id, forceinfo@ force_t, int id, string talent_name)
		{
			string force_name = pk::decode(pk::get_name(pk::get_force(force_id)));
			switch (id)
			{
			case 9:
				pk::fade(0);
				pk::sleep();
				pk::background("mediaEX/background/talent/retire.png");
				pk::fade(255);
				
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x忍受不住严格的指导，因此离开\x1b[02x{}\x1b[0x。", talent_name, force_name)));
				pk::fade(0);
				pk::sleep();
				pk::background(-1);
				pk::fade(255);
				break;
			case 11:
				pk::fade(0);
				pk::sleep();
				pk::background("mediaEX/background/talent/retire.png");
				pk::fade(255);
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x因返乡探亲之故，离开\x1b[02x{}\x1b[0x。", talent_name, force_name)));
				pk::fade(0);
				pk::sleep();
				pk::background(-1);
				pk::fade(255);
				break;
			case 12:
				pk::fade(0);
				pk::sleep();
				pk::background("mediaEX/background/talent/retire.png");
				pk::fade(255);
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x决定流浪旅行，因而离\x1b[02x{}\x1b[0x。", talent_name, force_name)));
				pk::fade(0);
				pk::sleep();
				pk::background(-1);
				pk::fade(255);
				break;
			default:
				break;
			}
			//force_t.time_extended = true;//源码是|=2，不知道啥意思
			force_t.is_out = true;

			return;
		}

		void talent_return_event()
		{
			
			//是否要确保指导老师不在期间也离开势力？
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);
			if (!force_t.is_out) return;//没发生离开事件的，就不判断了
			pk::person@ talent = pk::get_person(force_t.talent_id);
			int eff = get_rand_int(talent.base_stat[武将能力_武力],100);
			pk::trace("return_event eff:" + eff + ",remained_time_eff:" + (force_t.remained_time*5) + ",giri_eff:" + (2 * talent.giri + 10));
			if (eff < int(5 * force_t.remained_time) or eff < int(2 * talent.giri + 10))//触发回归的条件
			{
				pk::trace("talent_start_return");
				//if (force_t.remained_time < 3) return;//时间不够，不发生返回

				pk::force@ force = pk::get_force(force_id);

				//pk::person@ talent = pk::get_person(force_t.talent_id);
				string talent_name = pk::decode(talent.sei + talent.mei);
				pk::person@ kunshu = pk::get_person(force.kunshu);
				string kunshu_name = pk::decode(pk::get_name(kunshu));
				pk::person@ teacher = pk::get_person(force_t.teacher_id);
				string teacher_name = pk::decode(pk::get_name(teacher));
				//回来应该要满足一定的条件，同时如果一定时间不回，就触发失踪事件，再也不回来

				if (ch::test_bit(force_t.train_event, 小兵事件_学生出走1))
				{
					pk::message_box(pk::encode("我后来静下来仔细思考后，觉得为大家带来困扰，我实在感到很抱歉。"), talent);
					pk::rand_bool(50) ? pk::message_box(pk::encode("回来就好。以崭新的心情重新出发，将未完成的份也一起练回来吧。"), teacher) : pk::message_box(pk::encode("回来就好。以崭新的心情重新出发，努力成为一名堂堂的武将吧。"), teacher);
					pk::message_box(pk::format("失去行踪的\x1b[01x{}\x1b[0x重返\x1b[01x{}军\x1b[0x。", talent_name, kunshu_name));
					force_t.is_out = false;
				}
				else if (ch::test_bit(force_t.train_event, 小兵事件_流浪旅行1))
				{
					pk::message_box(pk::encode("\x1b[01x{}\x1b[0x大人，流浪期间多方面自省之余，我领悟到自身的肤浅。"), talent);
					pk::rand_bool(50) ? pk::message_box(pk::encode("回来就好。以崭新的心情重新出发，将未完成的份也一起练回来吧。"), teacher) : pk::message_box(pk::encode("回来就好。以崭新的心情重新出发，努力成为一名堂堂的武将吧。"), teacher);
					pk::message_box(pk::format("失去行踪的\x1b[01x{}\x1b[0x重返\x1b[01x{}军\x1b[0x。", talent_name, kunshu_name));
					force_t.is_out = false;
				}
				else if (ch::test_bit(force_t.train_event, 小兵事件_返乡探亲))
				{
					pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人, 返乡探亲之际给您添麻烦了。", teacher_name)), talent);
					pk::rand_bool(50) ? pk::message_box(pk::encode("回来就好。以崭新的心情重新出发，将未完成的份也一起练回来吧。"), teacher) : pk::message_box(pk::encode("回来就好。以崭新的心情重新出发，努力成为一名堂堂的武将吧。"), teacher);
					pk::message_box(pk::format("四处流浪的\x1b[01x{}\x1b[0x重返\x1b[01x{}军\x1b[0x。", talent_name, kunshu_name));
					force_t.is_out = false;
				}
			}

			return;
		}

		void talent_disapear_event()
		{
			int force_id = pk::get_current_turn_force_id();
			auto force_t = ch::get_force_p(force_id);

			//额外加入老师身份变化引起的学生消失事件
			int check_result = check_teacher_status(force_t);
			if (check_result != 0)
			{
				pk::person@ talent = pk::get_person(force_t.talent_id);
				string talent_name = pk::decode(talent.sei + talent.mei);
				//pk::force@ force = pk::get_force(force_id);
				//pk::person@ kunshu = pk::get_person(force.kunshu);
				//string kunshu_name = pk::decode(pk::get_name(kunshu));
				if (check_result == 2) pk::message_box(pk::format("随行的\x1b[01x{}\x1b[0x似乎也同时失陷于乱军中，从此音讯全无了。", talent_name));
				if (check_result == 1 or check_result == 3)
					pk::message_box(pk::format("承受不住老师死亡的打击，\x1b[01x{}\x1b[0x意志消沉，无心训练，默默离开了。", talent_name));
				//身份清空，数据重置
				talent.mibun = 身份_无;//只要是身份无，就可以被用起来了，其他倒不需要处理
				force_t.init_talent_info();
			}

			//后续本来的学生消失事件
			if (!force_t.is_out) return;//没发生离开事件的，就不判断了
			//pk::trace("disapear out_time:" + force_t.out_time + "学生出走1" + ch::test_bit(force_t.train_event, 小兵事件_学生出走1) + "流浪旅行1" + ch::test_bit(force_t.train_event, 小兵事件_流浪旅行1) + "返乡探亲" + ch::test_bit(force_t.train_event, 小兵事件_返乡探亲));
			if (force_t.out_time > 5) 
			{
				pk::force@ force = pk::get_force(force_id);
				pk::person@ talent = pk::get_person(force_t.talent_id);
				string talent_name = pk::decode(talent.sei + talent.mei);
				//pk::person@ kunshu = pk::get_person(force.kunshu);
				//string kunshu_name = pk::decode(pk::get_name(kunshu));
				if (ch::test_bit(force_t.train_event, 小兵事件_学生出走1))
				{
					pk::message_box(pk::format("失去行踪的\x1b[01x{}\x1b[0x从此音讯全无了。", talent_name));

				}
				else if (ch::test_bit(force_t.train_event, 小兵事件_流浪旅行1))
				{
					pk::message_box(pk::format("失去行踪的\x1b[01x{}\x1b[0x从此音讯全无了。", talent_name));

				}
				else if (ch::test_bit(force_t.train_event, 小兵事件_返乡探亲))
				{
					pk::message_box(pk::format("四处流浪的\x1b[01x{}\x1b[0x从此音讯全无了。", talent_name));

				}
				//清空对应武将数据，再清空势力的附加数据
				talent.mibun = 身份_无;//只要是身份无，就可以被用起来了，其他倒不需要处理
				force_t.init_talent_info();
			}
		}

		int check_teacher_status(forceinfo @ force_t)
		{
			//小兵培养进行中，老师身份为俘虏的情况，需要触发小兵消失事件，防止bug
			auto teacher = pk::get_person(force_t.teacher_id);
			if (!pk::is_alive(teacher)) return 1;
			if (teacher.mibun == 身份_俘虏) return 2;
			if (teacher.mibun == 身份_死亡) return 3;
			return 0;
			//身份为死亡时，如何处理？
		}

		int talent_status_release(forceinfo@ force_t)
		{
			//抄的源码，感觉可以更精简
			int result = force_t.talent_status - 2;
			if (force_t.talent_status == 2)
			{
				force_t.talent_status = 1;
			}
			else
			{
				result = force_t.talent_status - 3;
				if (force_t.talent_status == 3)
				{
					force_t.talent_status = 2;
				}
				else
				{
					result = force_t.talent_status - 4;
					if (force_t.talent_status == 4)
						force_t.talent_status = 3;
				}
			}
			return result;
		}

		void scen_小兵兵法培养(bool fatigue = false)
		{
			int force_id = pk::get_current_turn_force_id();
			pk::force@ force = pk::get_force(force_id);
			pk::person@ kunshu = pk::get_person(force.kunshu);
			string kunshu_name = pk::decode(pk::get_name(kunshu));
			auto force_t = ch::get_force_p(force_id);
			//pk::person@ promoter = pk::get_person(force_t.discovered_by);
			//string promoter_name = pk::decode(pk::get_name(promoter));
			pk::person@ talent = pk::get_person(force_t.talent_id);
			string talent_name = pk::decode(talent.sei + talent.mei);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			string teacher_name = pk::decode(pk::get_name(teacher));
			/**/
			//12850 12854 12858
			if (kunshu.get_id() != teacher.get_id()) pk::message_box(pk::encode(pk::format("主公，\n想请教您对指导\x1b[01x{}\x1b[0x兵法的意见。", talent_name)), teacher);
			switch (pk::rand(3))
			{
			case 0:
				pk::message_box(pk::encode(pk::format("不妨偶尔试着传授\x1b[01x{}\x1b[0x其它兵法。", talent_name)), kunshu);
				break;
			case 1:
				pk::message_box(pk::encode(pk::format("不妨试着考虑其它兵法，\n以增广\x1b[01x{}\x1b[0x的才能。", talent_name)), kunshu);
				break;
			case 2:
				pk::message_box(pk::encode(pk::format("偶尔传授其他兵法给\x1b[01x{}\x1b[0x也不错。", talent_name)), kunshu);
				break;
			default:
				break;
			}
			if (kunshu.get_id() != teacher.get_id())
			{
				pk::rand_bool(50)? pk::message_box(pk::encode(pk::format("好吧！\n我会考虑看看。", talent_name)), teacher):pk::message_box(pk::encode(pk::format("嗯，\n我会考虑看看！", talent_name)), teacher);
			}
			else
			{
				pk::message_box(pk::encode("那么，\n我该传授什么才好呢……？"), teacher);
			}

			//这是选择项目的函数了，ida里看到分在另一个函数里
			
			array<int> 项目ID = ch::get_x_rand_int(0, 训练项目.length, 4, get_unavailable_num(talent));
			//请选择对{}的指导内容。---TODO还得加上如果对应兵法(适性)满了，应该不出现对应选项
			array<string> answers =
			{
				pk::encode(训练项目[项目ID[0]]),
				pk::encode(训练项目[项目ID[1]]),
				pk::encode(训练项目[项目ID[2]]),
				pk::encode(训练项目[项目ID[3]]) };

			int confirm_value = pk::choose(pk::encode(pk::format("请选择对\x1b[01x{}\x1b[0x的指导内容。",talent_name)), answers);
			
			if (kunshu.get_id() != teacher.get_id())
			{
				pk::rand_bool(50) ? pk::message_box(pk::encode("遵命。\n臣将努力指导以不负您的期望。"), teacher) : pk::message_box(pk::encode("感谢您宝贵的意见。\n臣将努力指导以不负您的期望。"), teacher);
			}
			else
			{
				pk::rand_bool(50) ? pk::message_box(pk::encode("既然已决定了，\n就打起精神随我修行吧！"), teacher) : pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n仔细听从我的话来修行。", talent_name)), teacher);

			}

			pk::fade(0);
			pk::sleep();
			pk::fade(255);
			pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n将你的学习成果演练给我看吧！", talent_name)), teacher);
			//播放习得兵法的动画
			//计算学习成果
			int study_result = get_tactic_study_reusult(force_t, teacher, talent, 项目ID[confirm_value], fatigue);//
			string tactic_desc = add_ability(force_t,talent, study_result, 项目ID[confirm_value]);
			//TODO学习效果，特殊功绩特技习得？
			//失败分4种 根据老师会不会，学生领悟能力好不好，分为4种
			//成功分2种 学得很好， 学得一般

			//无所属所在，所以才看不到名字？---因为is_active判断
			switch (study_result)
			{
			case 0://老师不会,学生领悟差
				pk::rand_bool(50) ? pk::message_box(pk::encode("……抱歉，\n我已不知所措。"), talent) : pk::message_box(pk::encode("……抱歉，\n我已不知所措。"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("硬要教我自己也\n不通晓的领域是勉强了点。"), teacher) : pk::message_box(pk::encode("传授别人自己未能理解的兵法，\n是错误的做法吧。"), teacher);
				break;
			case 1://老师会，学生领悟差
				pk::rand_bool(50) ? pk::message_box(pk::encode("……行不通。\n不了解你说的意思。"), talent) : pk::message_box(pk::encode("……行不通。\n不知从何处下手才好……"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("为什么…… ？\n我已教得很仔细，\n难不成这超出\x1b[01x{}\x1b[0x能力？", talent_name)), teacher) : pk::message_box(pk::encode(pk::format("现在就教\x1b[01x{}\x1b[0x这些，\n还嫌太早吗？", talent_name)), teacher);
				break;
			case 2://老师会，学生领悟好
				pk::rand_bool(50) ? pk::message_box(pk::encode("……不行。\n虽然已经照所学的做了……。"), talent) : pk::message_box(pk::encode("……不行。\n虽然自认明白所学的东西，但……。"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("为何失败？\n难不成是用错了教法？"), teacher) : pk::message_box(pk::encode(pk::format("竟然不成……？\n想不到指导\x1b[01x{}\x1b[0x还挺困难的。",talent_name)), teacher);
				break;
			case 3://老师不会，学生领悟好
				pk::rand_bool(50) ? pk::message_box(pk::encode("……行不通。\n总不得要领。"), talent) : pk::message_box(pk::encode("……行不通。\n似乎完全学不会。"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("连我自己也未能领悟，你也不用责备自己。"), teacher) : pk::message_box(pk::encode("我也未能领悟该透彻，当然教得不好。"), teacher);
				break;
			case 4:
				pk::rand_bool(50) ? pk::message_box(pk::encode("完成了！\n总算学会了！"), talent) : pk::message_box(pk::encode("承蒙您的教导，\n我才得以成功！"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("记得挺熟的，看来我的教导也得到代价了。"), teacher) : pk::message_box(pk::encode("确实学得我所教的，\n真不错。"), teacher);
				break;
			case 5:
				pk::rand_bool(50) ? pk::message_box(pk::encode("成了！\n我已领悟个中真谛！"), talent) : pk::message_box(pk::encode("哈哈！\n此中精妙已尽在掌握！"), talent);
				pk::rand_bool(50) ? pk::message_box(pk::encode("做得好！\n竟能有此表现，\n令我深深佩服……。"), teacher) : pk::message_box(pk::encode("精彩！\n我们的努力也得到代价了。"), teacher);
				break;
			default:
				break;
			}
			//xx的相应能力获得了{大幅}{}{些许}增长
			//xx学得了{}--根据前后适性变化
			//xx的xx适性上升了？
			string stat_desc = study_result < 4 ? "些许" : (study_result == 4 ?"":"大幅");
			pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的相应能力获得了\x1b[02x{}\x1b[0x增长。", talent_name, stat_desc)));

			if (tactic_desc != "")
			{
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的\x1b[02x{}\x1b[0x适性上升了。", talent_name, tactic_desc)));
			}
			/*
			string tactic_name = "突击";//TODO 根据学习结果生成文字
			if (study_result < 4) pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x学不成\x1b[02x{}\x1b[0x", talent_name, tactic_name)));
			else
			{
				//老师和学生一起学得兵法
				//学生学得单一兵法
				//学生学得多项兵法
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x学得\x1b[02x{}\x1b[0x了", talent_name, tactic_name)));
			}*/
		}

		void scen_小兵领悟兵法()
		{

			int force_id = pk::get_current_turn_force_id();
			pk::force@ force = pk::get_force(force_id);
			pk::person@ kunshu = pk::get_person(force.kunshu);
			string kunshu_name = pk::decode(pk::get_name(kunshu));
			auto force_t = ch::get_force_p(force_id);
			pk::person@ talent = pk::get_person(force_t.talent_id);
			string talent_name = pk::decode(talent.sei + talent.mei);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			string teacher_name = pk::decode(pk::get_name(teacher));

			array<int> exception_item = {255};
			if (force_t.teaching_method == 0)
			{
				exception_item = { 0, 1, 2, 3, 4 };
			}
			else if (force_t.teaching_method == 2)
			{
				exception_item = { 5, 6, 7, 8, 9, 10 };
			}
			array<int> unavailable_num = get_unavailable_num(talent);
			for (int i = 0; i < int(exception_item.length); ++i)
			{
				unavailable_num.insertLast(exception_item[i]);
			}

			array<int> 项目ID = ch::get_x_rand_int(0, 训练项目.length, 1, unavailable_num);
			//领悟默认成功
			int study_result = 4;
			string tactic_desc = add_ability(force_t, talent, study_result, 项目ID[0]);

			//string tactics_name = "突击";
			array<string> teacher_say = { "学得不错，\n这也是你精益求精的成果。",
				"你竟然可以办到……！\n我也替你感到高兴。",
				pk::format("\x1b[01x{}\x1b[0x，努力得到了回报，\n如同我也得到了回报，真是令人欢欣。",talent_name)
			};
			//领悟对应项目的说法
			
			pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x大人！我在\x1b[02x{}\x1b[0x上有了新的领悟！",teacher_name, 项目描述[项目ID[0]])), talent) : pk::message_box(pk::encode(pk::format("由于\x1b[01x{}\x1b[0x大人的细心指导，\n我在\x1b[02x{}\x1b[0x上的造诣进一步加深了。", teacher_name, 项目描述[项目ID[0]])), talent);
			
			pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
			//TODO老师同时学得的条件
			/*
			if (false)
			{
				pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("和你一同钻研的结果，\n连我也学得了\x1b[02x{}\x1b[0x，实在感到很高兴。！", tactics_name)), teacher) : pk::message_box(pk::encode(pk::format("我也学得了\x1b[02x{}\x1b[0x，\n和你共同付出的辛劳总算没有白费。",  tactics_name)), teacher);
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x和\x1b[01x{}\x1b[0x学得\x1b[02x{}\x1b[0x了", talent_name, tactics_name)));
			}*/

			string stat_desc = study_result < 4 ? "些许" : (study_result == 4 ? "" : "大幅");
			pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的相应能力获得了\x1b[02x{}\x1b[0x增长。", talent_name, stat_desc)));

			if (tactic_desc != "")
			{
				pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x的\x1b[02x{}\x1b[0x适性上升了。", talent_name, tactic_desc)));
			}
		}

		void scen_小兵兵法培养2()//不确定此种何时触发，难道是不选择躬亲时？因为直接就演练了，没有选择过程
		{
			int force_id = pk::get_current_turn_force_id();
			pk::force@ force = pk::get_force(force_id);
			pk::person@ kunshu = pk::get_person(force.kunshu);
			string kunshu_name = pk::decode(pk::get_name(kunshu));
			auto force_t = ch::get_force_p(force_id);
			pk::person@ talent = pk::get_person(force_t.talent_id);
			string talent_name = pk::decode(talent.sei + talent.mei);
			pk::person@ teacher = pk::get_person(force_t.teacher_id);
			string teacher_name = pk::decode(pk::get_name(teacher));

			pk::fade(0);
			pk::sleep();
			pk::fade(255);
			pk::message_box(pk::encode(pk::format("\x1b[01x{}\x1b[0x，\n将你的学习成果演练给我看吧！", talent_name)), teacher);
			pk::message_box(pk::encode("遵命！"), talent);

			array<int> exception_item = { 255 };
			if (force_t.teaching_method == 0)
			{
				exception_item = { 0, 1, 2, 3, 4 };
			}
			else if (force_t.teaching_method == 2)
			{
				exception_item = { 5, 6, 7, 8, 9, 10 };
			}
			array<int> unavailable_num = get_unavailable_num(talent);
			for (int i = 0; i < int(exception_item.length); ++i)
			{
				unavailable_num.insertLast(exception_item[i]);
			}

			array<int> 项目ID = ch::get_x_rand_int(0, 训练项目.length, 1, unavailable_num);
			//兵法3默认特别成功
			string tactic_desc = add_ability(force_t, talent, 5, 项目ID[0]);


			string tactics_name = 项目描述[项目ID[0]];
			array<string> teacher_say = { pk::format("……\n精彩得无可挑剔，\n在\x1b[02x{}\x1b[0x上，你早晚超越为师。",tactics_name),
				"嗯，悟性很棒！\n确实学得我所教授的东西了。",
				pk::format("……\n精彩极了，\n你在\x1b[02x{}\x1b[0x上的造诣真是一日千里！",tactics_name),
				"嗯，悟性很棒！\n你确实学得我所教授的东西。"
			};
			pk::message_box(pk::encode(teacher_say[pk::rand(teacher_say.length)]), teacher);
			pk::rand_bool(50) ? pk::message_box(pk::encode(pk::format("多亏\x1b[01x{}\x1b[0x大人的教导，\n才能有此成果，\n在下打从心底深深致谢。", teacher_name)), talent) : pk::message_box(pk::encode(pk::format("感谢有\x1b[01x{}\x1b[0x大人的教导，\n此番努力真有价值。", teacher_name)), talent);
			//TODO 看不懂的后续处理
		}

		//////////////////////////////////////////////////人才生成相关函数//////////////////////////////////////////////////////////////////////
		pk::person@ getEmptyPerson()
		{
			pk::person@ person;
			// 子嗣检查
			for (int i = 0; i < 1000; i++)
			{
				flag_has_child[i] = false;
			}
			for (int p = 0; p < 1000; p++)
			{
				@person = pk::get_person(p);
				if (person.generation <= 1)  continue;  //跳过世代小于1的武将
				if (person.father >= 0 && person.father <= 1000) flag_has_child[person.father] = true;
				if (person.mother >= 0 && person.mother <= 1000) flag_has_child[person.mother] = true;
			}

			if (slot_新武将)
			{
				for (int i = 999; i >= /*850*/900; i--)
				{
					if (testEmptyPerson(i)) return pk::get_person(i);
				}
			}
			if (slot_古武将)
			{
				for (int i = 849; i >= 850; i--)
				{
					if (testEmptyPerson(i)) return pk::get_person(i);
				}
			}
			if (slot_史实武将)
			{
				for (int i = 699; i >= 0; i--)
				{
					if (testEmptyPerson(i)) return pk::get_person(i);
				}
			}
			return null;
		}

		bool testEmptyPerson(int id)
		{
			pk::person@ new_person = pk::get_person(id);
			
			if (flag_has_child[id])     return false;   //跳过有孩子的武将id
			if (new_person.mibun == 身份_无 or new_person.mibun == 身份_死亡)  return true;     //跳过活着的武将id
			return false;
		}


		int initNewPerson(pk::person@ new_person, int sex, pk::person@ person/*提拔者*/, int good, int bad, int excellent)
		{
			string title;
			int buff_stat_min = 0, buff_stat_max = 0, buff_tekisei = 0;
			int best_stat = -1, best_stat_value = -1;
			int stat_sum = 0, luck = 0;
			int person_type = -1, talent_type = -1;

			person_type = randint(0, 5);   //随机一种类型
			if (person !is null) {
				if (类型同提拔者 or pk::rand_bool(33))	person_type = getPersonType(person);
			}

			if (pk::rand_bool(good))
			{
				buff_stat_min += 50;
				buff_stat_max += 25;
				buff_tekisei += 2;
			}
			else if (pk::rand_bool(int(bad / ((100 - good) / 100.f))))  // 确保概率准确
			{
				buff_stat_min -= 40;
				buff_stat_max -= 40;
				buff_tekisei -= 2;
			}
			if (pk::rand_bool(excellent))
			{
				person_type = 6;
				buff_stat_min = 0;
				buff_stat_max = 0;
				buff_tekisei = 0;
				luck += 8;
			}

			//	性别
			new_person.sex = sex;
			//  姓名字号
			init_name(new_person, sex);
			//  基本信息
			init_normal(new_person);
			init_relation(new_person);
			init_model(new_person, sex, person_type);
			//	能力值
			stat_sum = init_ability(new_person, person_type, buff_stat_min, buff_stat_max, buff_tekisei);
			best_stat = get_best_stat(new_person);
			best_stat_value = new_person.base_stat[best_stat]/ 新人才能力倍率*100;//因为前面已经处理过倍率了，所以此处还原

			if (person_type == 6) {
				talent_type = 16;
				title = "翘楚";
			}
			else {
				switch (best_stat)
				{
					/*
					统率	勇将0	帅才8
					武力	勇将1	猛将9
					智力	学者2	谋士10
					政治	学者3	政才11
					魅力	名人4	名流12
					全能			翘楚16
					*/
				case 0:
					if (best_stat_value < 85) { talent_type = 0; title = "勇将"; }
					else { talent_type = 8; title = "帅才"; }		break;
				case 1:
					if (best_stat_value < 85) { talent_type = 1; title = "勇将"; }
					else { talent_type = 9; title = "猛将"; }		break;
				case 2:
					if (best_stat_value < 85) { talent_type = 2; title = "学者"; }
					else { talent_type = 10; title = "谋士"; }	break;
				case 3:
					if (best_stat_value < 85) { talent_type = 3; title = "学者"; }
					else { talent_type = 11; title = "政才"; }	break;
				case 4:
					if (best_stat_value < 85) { talent_type = 4; title = "名人"; }
					else { talent_type = 12; title = "名流"; }	break;
				default:
				{ talent_type = -1; title = "人才"; }	break;
				}
			}

			//	特技
			init_skill(new_person, talent_type);//特技并没有考虑能力数值

			//pk::trace(pk::format("after int_skill chance：{}", 1));
			new_person.name_read = pk::encode(title);
			new_person.update();
			//pk::trace("人才选拔，智力" + new_person.base_stat[武将能力_智力]);
			if (false) new_person::limit_skill_set(new_person);//, (talent_type > 8 ? 特技_进修::一级特技概率 : 0));//用以替换原版新人才系统特技设定，看效果
			if (best_stat_value >= 70)	luck += 1;
			if (best_stat_value >= 85)	luck += 1;
			if (stat_sum >= 250)		luck += 1;
			if (stat_sum >= 290)		luck += 1;
			if (stat_sum >= 320)		luck += 1;
			if (stat_sum >= 350)		luck += 1;
			if (stat_sum >= 380)		luck += 1;

			return luck;
		}

		void init_name(pk::person@ new_person, int sex)
		{
			new_person.sei = pk::encode(sei_[pk::rand(sei_.length)]);
			if (use_designated_name)
			{
				if (sex == 0)   new_person.mei = pk::encode(mei_m[pk::rand(mei_m.length)]);
				else            new_person.mei = pk::encode(mei_f[pk::rand(mei_f.length)]);
			}
			else {
				new_person.mei = pk::get_family_name(randint(성씨_끝 - 1)).name;
			}
			if (sex == 0 && pk::rand_bool(33))   //部分男性有字号
				new_person.azana = pk::encode(azana_0[pk::rand(azana_0.length)]) + pk::get_family_name(randint(성씨_끝 - 1)).name;
			else
				new_person.azana = "";
			new_person.name_read = "";
			new_person.azana_read = "";
		}

		void init_normal(pk::person@ new_person)
		{
			new_person.appearance = pk::get_year();                 //登场年
			new_person.birth = pk::get_year() - randint(17, 40);    //出生年
			new_person.death = new_person.birth + randint(50, 75);  //死亡年
			new_person.cause_of_death = 0;                          //死因
			new_person.estimated_death = false;                     //死亡预定
			new_person.longevity = false;
			new_person.shoubyou = 0;                                //伤病
			new_person.absence_timer = 0;                           //
			new_person.prisoner_timer = 0;                          //
			new_person.ban_timer = 0;                               //
			new_person.former_force = -1;                           //
			new_person.banned_kunshu = -1;                          //
			new_person.action_done = true;							//

			new_person.birthplace = randint(주_유주, 주_남중);   							//出生地
			new_person.wadai = randint(화제_고사, 화제_시절);    							//特长话题
			new_person.giri = randint(义理_低, 义理_高); 						//义理
			new_person.ambition = randint(野心_高, 野心_低);						//野心
			new_person.promotion = randint(기용_능력, 기용_임의);							//任用
			new_person.character = randint(성격_소심, 성격_저돌);    						//性格
			new_person.kanshitsu = randint(한실_무시, 한실_중시);    						//汉室态度
			new_person.strategic_tendency = randint(전략경향_중화통일, 전략경향_현상유지);   //战略倾向
			new_person.local_affiliation = randint(지역집착_지역중시, 지역집착_지역무시);    //地缘执着
		}

		void init_relation(pk::person@ new_person)
		{
			new_person.ketsuen = new_person.get_id();   //血缘
			new_person.generation = 1;                  //世代
			new_person.aishou = randint(0, 150);         //相性
			new_person.father = -1;                     //父亲
			new_person.mother = -1;                     //母亲
			new_person.spouse = -1;                     //配偶
			new_person.gikyoudai = -1;                  //义兄
			for (int i = 0; i < 5; i++)
			{
				new_person.liked[i] = -1;				//喜爱
				new_person.disliked[i] = -1;			//厌恶
			}
		}

		void init_belong(pk::person@ new_person, pk::building@ building, bool office/*仕官*/ = true, int mibun = 3, int loyalty = 100, int kouseki = 0)
		{
			new_person.mibun = mibun;        							//身份
			new_person.loyalty = loyalty;           					//忠诚度
			new_person.kouseki = kouseki;          						//功绩
			int building_id = building.get_id();
			new_person.service = building_id;
			new_person.location = building_id;
			pk::move(new_person, building);       						//所属、所在

			//int force_id = building.get_force_id();
			//auto force_t = ch::get_force_p(force_id);
			
			if (office)
			{
				new_person.absence_timer = 0;                              //清空不在期间
				new_person.appearance = pk::get_year()+2;//登场年后延，防止提前被发现
				int force_id = building.get_force_id();
				auto force_t = ch::get_force_p(force_id);
				auto person_t = ch::get_person_p(force_t.talent_id);
				person_t.train_event = force_t.train_event;
				person_t.discovered_by = force_t.discovered_by;
				person_t.teacher_id = force_t.teacher_id;
				person_t.person_type = 5;//小兵提拔
				person_t.appeared_reason = 1;//登场原因：0-无，1-提拔，2-请求仕官，3-受赏识，4-后代
				person_t.init_force = force_id;
				pk::set_district(new_person, building.get_district_id());	//军团
			}
			else
			{
				new_person.absence_timer = 24;                              //设置不在期间，防止被发现登用
				new_person.appearance = pk::get_year() + 1;
			}

			new_person.update();
		}

		void init_model(pk::person@ new_person, int sex, int person_type)
		{
			if (sex == 0)
			{
				bool wujiang = true;  //类型为武将初始化
				if (person_type == 0 || person_type == 1 || person_type == 6)  //帅才、猛将、翘楚时调用武官头像
					new_person.face = randint(2050, 2099); //头像
				else  //军师、文臣、谋士、名人调用文官头像
				{
					wujiang = false;
					new_person.face = randint(2000, 2049); //头像
				}
				new_person.voice = randint(음성_소심남, 음성_저돌남);  //声音-男
				new_person.tone = randint(말투_장비, 말투_보통남);     //語气-男
				//  武将造型
				new_person.skeleton = 0;
				if (wujiang)  //为武将
				{
					array<int> new_person_body = { 75, 76, 84, 85, 93, 94, 102, 103, 111, 112, 120, 121 };  //武官的基本造型
					int rd_n = new_person_body[pk::rand(12)];
					new_person.body[0] = rd_n;
					new_person.body[1] = rd_n;
					new_person.body[2] = rd_n;
					new_person.body[3] = rd_n;
					new_person.body[4] = rd_n;
					new_person.body[5] = rd_n;
				}
				else
				{
					array<int> new_person_body = { 79, 80, 88, 89, 97, 98, 106, 107, 115, 116, 124, 125 };  //文官的基本造型
					int rd_n = new_person_body[pk::rand(12)];
					new_person.body[0] = rd_n;
					new_person.body[1] = rd_n;
					new_person.body[2] = rd_n;
					new_person.body[3] = rd_n;
					new_person.body[4] = rd_n;
					new_person.body[5] = rd_n;
				}
			}
			else
			{
				bool wujiang = true;  //类型为武将初始化
				if (person_type == 0 || person_type == 1 || person_type == 6)  //帅才、猛将、翘楚时调用武官头像
					new_person.face = randint(2150, 2182); //头像
				else  //军师、文臣、谋士、名人调用文官头像
				{
					wujiang = false;
					new_person.face = randint(2100, 2132); //头像
				}
				new_person.voice = randint(음성_냉정녀, 음성_대담녀);   //声音-女
				new_person.tone = randint(말투_고대만족, 말투_보통녀);  //語气-女
				//  武将造型
				new_person.skeleton = 1;  //更换为女性骨架
				if (wujiang)  //为武将
				{
					array<int> new_person_body = { 77, 78, 86, 87, 95, 96, 104, 105, 113, 114, 122, 123 };  //武官的基本造型
					int rd_n = new_person_body[pk::rand(12)];
					new_person.body[0] = rd_n;
					new_person.body[1] = rd_n;
					new_person.body[2] = rd_n;
					new_person.body[3] = rd_n;
					new_person.body[4] = rd_n;
					new_person.body[5] = rd_n;
				}
				else
				{
					array<int> new_person_body = { 81, 82, 90, 91, 99, 100, 108, 109, 117, 118, 126, 127 };  //文官的基本造型
					int rd_n = new_person_body[pk::rand(12)];
					new_person.body[0] = rd_n;
					new_person.body[1] = rd_n;
					new_person.body[2] = rd_n;
					new_person.body[3] = rd_n;
					new_person.body[4] = rd_n;
					new_person.body[5] = rd_n;
				}
			}
		}

		int init_ability(pk::person@ new_person, int person_type, int buff_stat_min, int buff_stat_max, int buff_tekisei)
		{
			//此处区别于人才选拔的地方在于，需要获取初始能力和能力上限
			//初始值就作为武将能力，能力上限存结构体
			array<int> range_stat_max = { 0,0,0,0,0 };
			array<int> range_stat_min = { 0,0,0,0,0 };
			array<int>  relative_stat = { 0,0,0,0,0 };
			array<int>  relative_max_stat = { 0,0,0,0,0 };
			int stat_sum, stat_min, stat_max;
			int chance_话术 = 0;

			switch (person_type)
			{
			case 0: //帅才
				range_stat_min = { 68, 45, 42, 5, 40 };
				range_stat_max = { 88, 75, 72, 45, 80 };
				stat_min = 230;
				stat_max = 310;
				buff_tekisei += 2;
				chance_话术 = 25;
				break;
			case 1: //猛将
				range_stat_min = { 60, 70, 25, 5, 40 };
				range_stat_max = { 80, 90, 65, 45, 80 };
				stat_min = 230;
				stat_max = 310;
				buff_tekisei += 2;
				chance_话术 = 25;
				break;
			case 2: //军师
				range_stat_min = { 50, 10, 65, 30, 40 };
				range_stat_max = { 80, 50, 85, 70, 80 };
				stat_min = 230;
				stat_max = 310;
				buff_tekisei += 1;
				chance_话术 = 40;
				break;
			case 3: //谋士
				range_stat_min = { 25, 10, 80, 40, 40 };
				range_stat_max = { 65, 50, 90, 80, 80 };
				stat_min = 230;
				stat_max = 310;
				buff_tekisei += 1;
				chance_话术 = 50;
				break;
			case 4: //文臣
				range_stat_min = { 25, 10, 45, 70, 40 };
				range_stat_max = { 65, 50, 75, 90, 80 };
				stat_min = 230;
				stat_max = 310;
				buff_tekisei += 1;
				chance_话术 = 45;
				break;
			case 5: //名人
				range_stat_min = { 30, 30, 30, 30, 40 };
				range_stat_max = { 80, 80, 80, 80, 80 };
				stat_min = 210;
				stat_max = 330;
				buff_tekisei += 1;
				chance_话术 = 30;
				break;
			case 6:	//翘楚
				range_stat_min = { 60, 60, 60, 60, 50 };
				range_stat_max = { 90, 90, 90, 90, 90 };
				stat_min = 330;
				stat_max = 380;
				buff_tekisei += 5;
				chance_话术 = 45;
			}
			stat_sum = randint(stat_min + buff_stat_min, stat_max + buff_stat_max);

			//人才能力倍率在整个计算结束后才进行，为了获得最初的最佳能力和能力倍率
			
			//	人才相对五维计算
			int relative_sum = 0;
			int relative_max_sum = 0;
			for (int i = 0; i < 武将能力_末; i++)
			{
				relative_stat[i] = randint(range_stat_min[i], range_stat_max[i]);
				relative_sum += relative_stat[i];
				//此处加入最大值的额外计算
				relative_max_stat[i] = range_stat_max[i] - 4 + pk::rand(10);
				relative_max_sum += relative_max_stat[i];
			}
			
			//	最终人才能力
			int final_stat = 0;
			int final_max_stat = 0;
			auto force_t = ch::get_force_p(pk::get_current_turn_force_id());//此处需注意
			for (int i = 0; i < 武将能力_末; i++)
			{
				final_stat = int(relative_stat[i] * stat_sum * 新人才能力倍率 / 100 / relative_sum);
				new_person.base_stat[i] = ch::inRange(final_stat, 1, 人才能力上限);
				force_t.init_stat[i] = new_person.base_stat[i];

				final_max_stat = pk::max(randint(50,70) ,int(relative_max_stat[i]));
				force_t.max_stat[i] = ch::inRange(final_max_stat, 1, 人才资质上限);

				new_person.stat_aging[i] = randint(능력성장_초지속형, 능력성장_장비형);
				if (调试模式) ch::debug(2, pk::format("stat_0{}, stat_1{}", relative_stat[i], final_stat));
			}

			//  武将适性基数
			new_person.tekisei[兵种_枪兵] = randint(0, 人才适性标准);
			new_person.tekisei[兵种_戟兵] = randint(0, 人才适性标准);
			new_person.tekisei[兵种_弩兵] = randint(0, 人才适性标准);
			new_person.tekisei[兵种_骑兵] = randint(0, 人才适性标准);
			new_person.tekisei[兵种_兵器] = randint(0, 人才适性标准);
			new_person.tekisei[兵种_水军] = randint(0, 人才适性标准);
			//  随机适性升级
			int troops_type;
			buff_tekisei += randint(0, 1);
			for (int i = 0; i < buff_tekisei; i++)
			{
				troops_type = randint(兵种_枪兵, 兵种_水军);
				if (new_person.tekisei[troops_type] >= 人才适性上限) continue;
				new_person.tekisei[troops_type] = new_person.tekisei[troops_type] + 1;
			}

			//	话术
			new_person.wajutsu_daikatsu = pk::rand_bool(chance_话术);  //大喝
			new_person.wajutsu_kiben = pk::rand_bool(chance_话术);     //诡辩
			new_person.wajutsu_mushi = pk::rand_bool(chance_话术);     //无视
			new_person.wajutsu_chinsei = pk::rand_bool(chance_话术);   //镇静
			new_person.wajutsu_gyakujou = pk::rand_bool(chance_话术);  //愤怒
			/**/
			return stat_sum;
		}

		void init_skill(pk::person@ new_person, int person_type)
		{
			//清空新武将的2,3特技
			new_person.skill2 = -1;
			new_person.skill3 = -1;
			return;
		}

		int getPersonType(pk::person@ person)
		{
			float 将帅值 = person.stat[武将能力_统率] * 0.65f + person.stat[武将能力_武力] * 0.30f + person.stat[武将能力_智力] * 0.15f;
			float 猛将值 = person.stat[武将能力_统率] * 0.30f + person.stat[武将能力_武力] * 0.75f;
			float 军师值 = person.stat[武将能力_统率] * 0.45f + person.stat[武将能力_智力] * 0.65f;
			float 谋士值 = person.stat[武将能力_智力] * 1.00f;
			float 文臣值 = person.stat[武将能力_政治] * 0.55f + person.stat[武将能力_智力] * 0.45f;
			float 名人值 = person.stat[武将能力_魅力] * 1.00f;

			array<float> 类型值 = { 将帅值, 猛将值, 军师值, 谋士值, 文臣值, 名人值 };
			int type = 0;

			//  选出最高的类型值
			for (int i = 1; i < 6; i++)
			{
				if (类型值[i] > 类型值[type]) type = i;
			}
			return type;
		}
		//	获得五维最高者
		int get_best_stat(pk::person@ person)
		{
			int best_stat = 0;
			for (int i = 1; i < 5; i++)
			{
				if (person.base_stat[i] > person.base_stat[best_stat]) best_stat = i;
			}
			return best_stat;
		}

		string 获取初始能力评价(int value)
		{
			/*
			三国志9设定
			初始值:
			非凡:>65
			有能:55-65
			平凡:45-55
			不捻:45以下
			*/
			if (value < 40) return "不稔";
			if (value < 50) return "平凡";
			if (value < 60) return "有能";
			return "非凡";
		}

		string 获取资质评价(int value)
		{
			/*
			三国志9设定
			资质能力:
			杰出:可以达到100
			卓著:可达9X
			有望:可达8X
			普通:达80以下
			*/
			if (value < 75) return "普通";
			if (value < 85) return "有望";
			if (value < 95) return "卓著";
			return "杰出";
		}

		string 获取成果评价(int value)
		{
			/*
				学习效果 :
			极差：10以下
				平凡：10以上
				良好：18以上
				奇迹：25以上
				余力含义 :

			*/
			if (value > 25) return "奇迹";
			if (value > 18) return "良好";
			if (value > 10) return "平凡";
			return "平庸";
		}

		string 获取余力评价(int value)
		{
			/*
		充分:还能长30以上
			适当 : 15以上
			些许 : 1以上
			毫无 : 1以下
			*/
			if (value < 1) return "毫无";
			if (value < 15) return "些许";
			if (value < 30) return "适当";
			return "充分";
		}

		int get_stat_sum(pk::person@ person)
		{
			if (!pk::is_alive(person)) return -1;
			int stat_sum = 0;
			for (int i = 0; i < 武将能力_末; ++i)
			{
				stat_sum += person.base_stat[i];
			}
			return stat_sum;
		}

		//三9小兵事件最喜欢用的比较函数
		int get_rand_int(int stat, int max)
		{
			//uint value = pk::get_tick_count();
			int seed = pk::get_tick_count();
			//int seed = 29420 * (1 + max + stat) % 32767;
			return pk::rand(100, seed);
		}
		
		//发现小兵的事件 - 消灭敌势力 攻陷敌都市 捕获敌武将 发动兵法
		void generate_talent_seed(pk::person@ discovered_by)
		{     
			//发现小兵的事件 - 消灭敌势力 攻陷敌都市 捕获敌武将 发动兵法
			//此时主要生成小兵的初始能力，最大能力，适性，相性
			//能力数值分布随发现武将？
			//初始能力在一定范围内正态分布？
			//干脆初始值随机，最大值随提拔者好了
			int force_id = discovered_by.get_force_id();
			if (!pk::is_valid_normal_force_id(force_id)) return;
			auto force_t = ch::get_force_p(force_id);
			if (pk::is_valid_person_id(force_t.talent_id)) return;
			uint mean_init = 50;
			uint diff = 15;
			if (pk::is_valid_person_id(force_t.discovered_by) and force_t.init_stat[0] > (mean_init - diff) and force_t.init_stat[0] < (mean_init + diff)) return;//已经有小兵了


			for (int i = 0; i < 武将能力_末; ++i)
			{
				force_t.init_stat[i] = pk::gen_normal_distribution_int(mean_init, diff);
				//force_t.max_stat[i] = pk::gen_normal_distribution_int(80, 20);
				//pk::trace(i + ":force_t.init_stat[i]" + force_t.init_stat[i] + "force_t.max_stat[i]" + force_t.max_stat[i]);
			}
			force_t.discovered_by = discovered_by.get_id();


		}
		
	}

	Main main;

}